C Data Types Interview Questions and Answers: 12 Model Answers with Output Traces
Prepare C fundamentals with speakable answers, portable type rules and step-by-step output traces for integer division, promotions and unsigned conversion.
KnowledgeGate Team
Exam prep & CS education

Saying that int stores whole numbers and float stores decimal values may answer the first prompt. Then the interviewer changes a literal, adds an unsigned operand or asks what C actually guarantees, and the memorised list stops working.
C type questions turn on evaluation order: 5 / 2 finishes as integer 2 before assignment, while 5 / 2.0 produces 2.5, -1 < 1U compares as unsigned, and the worked mixed expression ends at 14.5.
1. C introduction questions: four precise answers
Question 1: What is C?
C is a general-purpose, procedural language with statically typed expressions, functions and explicit pointer access to addresses. It is often translated to native code, but is not merely low-level. It exposes representation, conversion, lifetime and memory reasoning.
Question 2: What normally happens between source code and an executable?
A common path: preprocessing -> compilation -> assembly -> linking. Preprocessing expands directives and macros; compilation translates C and reports diagnostics; assembly produces object code; linking resolves symbols and combines objects and libraries. It is not mandatory.
Question 3: What forms of main should a hosted C program use?
Use int main(void) or int main(int argc, char *argv[]); char **argv is an equivalent spelling. Reaching the end of main, or returning 0, reports success. void main() is not a standard hosted form, although an implementation may document others.
Question 4: What is the difference between a declaration and a definition?
extern int total; declares an object without defining it in that translation unit; int total = 0; defines it. int add(int, int); declares a function; int add(int a, int b) { return a + b; } defines it. Every definition is a declaration, but not every declaration is a definition. Continue with C Programming Interview Questions for Freshers: 40 Answered.
2. C type families, bytes and ranges
Question 5: What are the main type families in C?
Integer types include character types, signed and unsigned integer types, and _Bool. Real floating types are float, double and long double; void denotes no value. Other forms include pointers, arrays, function types, structures, unions and enumerations. Not all are fundamental scalar types.
Question 6: Is an int always four bytes, and is one byte always eight bits?
No. sizeof(char) is always 1, but a C byte has CHAR_BIT bits. Implementations choose the widths of short, int, long and long long while preserving required rank and range relationships. sizeof returns size_t, printed with %zu. Check ranges in <limits.h>. Use int32_t from <stdint.h> only when that exact-width type exists.
Claim | Portable answer | How to check |
|---|---|---|
| always |
|
| common, not universal |
|
| implementation-dependent |
|
| only when an exact 32-bit integer type is provided | test the implementation's |
3. Literals, initial values and typedef
Question 7: What types do common literals have?
10 is int, 10U is unsigned int, 10L is long, 10.0 is double, 10.0f is float, and 'A' is int in C. Literal types participate before assignment, so changing 2 to 2.0 can change the calculation.
Question 8: What default value does a variable receive?
Storage duration decides. An object with static storage duration is zero-initialised without an initializer, so static int attempts; starts at 0. An uninitialised automatic local such as int attempts; has an indeterminate value and must be assigned before reading. Not every variable defaults to zero.
Question 9: Does typedef create a new runtime type?
No, not for an alias. typedef unsigned long user_id; renames unsigned long; user_id id = 7UL; follows the underlying integer rules. The benefit is clearer interfaces and simpler declarations, not class-like type safety or runtime checking.
4. Promotions and usual arithmetic conversions
Question 10: What are integer promotions?
Types below the rank of int, such as signed char and short, promote before most arithmetic. With signed char a = 100, b = 25;, both promote to int, so a + b is int 125, not signed char arithmetic.
Question 11: Why does double half = 5 / 2 store 2.0 instead of 2.5?
Both operands are int, so 5 / 2 produces int 2, then assignment converts it to double 2.0. In double half = 5 / 2.0;, 5 converts before division, producing 2.5. A destination type cannot retroactively change completed arithmetic.
Question 12: Why is -1 < 1U false?
1U is unsigned int, so the usual arithmetic conversions turn int -1 into UINT_MAX. The comparison is false, value 0. Assuming UINT_MAX = 4,294,967,295, it becomes 4,294,967,295 < 1.

5. Fully worked interview trace: why the program prints 14.5
Find the output and every intermediate type:
signed char a = 100;
signed char b = 25;
double score = 5 / 2 + (double)(a + b) / 10;
printf("%.1f\n", score);The left branch gives 5 / 2 = int 2. On the right, a and b promote, so 100 + 25 = int 125. The cast gives double 125.0; 10 becomes double 10.0; division gives 12.5. Finally, 2 becomes double 2.0, and 2.0 + 12.5 = 14.5. The program prints 14.5 and a newline.
Subexpression | Operand types after conversion | Value | Result type |
|---|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
For an intended first term of 2.5, write 5.0 / 2 or cast before division.

6. Follow-up traps: conversion, overflow, char and printf
Assume UCHAR_MAX = 255. In unsigned char u = 250; u = u + 10;, u promotes to int, addition produces 260, then conversion modulo 256 stores 4. In contrast, int s = INT_MAX; s = s + 1; causes signed overflow, with no defined result. Do not predict guaranteed wraparound to INT_MIN.
Plain char may be signed or unsigned, so choose explicitly when it matters. In variadic printf, float promotes to double. Use %f for that value, %Lf for long double, and %zu for a sizeof result.
Expression | Defined result | Why |
|---|---|---|
|
| integer division |
|
|
|
stated eight-bit conversion |
| modulo |
| no defined result | signed overflow |
Read Data Types and Operators in C: Promotion, Overflow Traps for deeper conversion rules.
7. Service and product interview lenses
A fundamentals-first or service-style screen may cover Questions 1 to 9 and one output check. A depth-oriented or product-style follow-up may start with Questions 10 to 12, then ask whether behaviour is portable, implementation-dependent or undefined, and how to repair it. These are preparation lenses, not universal processes. Employers can combine both.
Use this spoken frame: (1) state the result or rule; (2) name types after promotions and conversions; (3) trace exact values; (4) state the portability or undefined-behaviour boundary when relevant. For -1 < 1U: result 0; common type unsigned int; values UINT_MAX and 1; comparison false.
For extra C practice, use the Interview & Resume Preparation Course or browse the Learn library for additional modules.
8. Thirty-second C data types recap and next step
Keep this checksum: declarations introduce names; definitions supply objects or function bodies; widths are implementation choices; literal types set the starting arithmetic; promotions precede most integer arithmetic; an assignment destination cannot rewrite a completed calculation.
Reproduce these results without notes: 5 / 2 = 2; 5 / 2.0 = 2.5; the worked expression prints 14.5; -1 < 1U is 0; with UCHAR_MAX = 255, converting 260 to unsigned char stores 4; INT_MAX + 1 has no defined result.
The C Language Course is the structured next step. State the rule, trace the values, then name the boundary.
Keep learning
C Programming MCQs: 12 Solved Intro & Data Types Questions with Explanations
Attempt 12 C Programming MCQs drawn from state, teacher-recruitment and placement-style papers, then use the worked explanations to fix each concept.
Flowchart Interview Questions and Answers: Symbols, Traces and Debugging
Learn how to define, draw, trace and debug flowcharts in an interview. Two worked examples cover a terminating sum loop and a maximum calculation that preserves a tie.
DBMS Data Models, Architecture and Components MCQs: 12 Solved Questions
Test whether you can separate data models, abstraction levels, catalogs, schemas and metadata. These 12 MCQs include concise explanations and a diagnostic review plan.
C Programming Data Types Explained: Concepts, Conversions and Worked Examples
Learn how C declarations, literal types, conversions, sizeof and format specifiers work. Follow one complete calculation and correct common objective-question traps.





