C Data Type Interview Questions and Answers: Sizes, Conversions, and Traps
Prepare for C interviews by learning what the standard guarantees and what depends on the implementation. Follow a complete integer-promotion trace, then review type selection and common output traps.
KnowledgeGate Team
Exam prep & CS education

Memorising char = 1 byte and int = 4 bytes is not enough for a C interview. A strong answer separates what the C language guarantees from what a particular compiler and machine choose. The aim is not to recite a size table. It is to track the type and value of every expression, especially when promotions and conversions occur. These model answers explain the reason behind each rule and build towards one complete conversion trace you can reproduce at the interview table.
What a C data type controls beyond byte size
A data type is a contract. It determines the set of values an object can hold, the operations permitted on those values, representation constraints, and how values participate in conversions.
C's fundamental types include:
_Boolfor truth valuescharacter types:
char,signed char, andunsigned charsigned and unsigned integer types
floating types:
float,double, andlong doublevoid, which represents the absence of a value or complete object type
Pointers, arrays, structures, and unions are constructed from these building blocks; their object and memory rules add another layer beyond fundamental types.
Model interview answer: A data type in C defines the values an object can represent and the operations and conversions that apply to it. Its size matters, but so do range, signedness, representation, and expression rules.
const and volatile are type qualifiers. They modify how a type may be used, but they do not replace the need to understand the underlying type. The earlier Intro & Data Types Interview Questions and Answers post owns C introduction, declarations, literals and default-value questions. The deeper interview layer is implementation-defined sizes, promotions, conversions, floating-point behaviour, type selection and output traps.
How to answer size, range, and signedness questions correctly
Do not begin with “int is 4 bytes”. C does not guarantee that. Begin with the portable facts: sizeof(char) == 1, one C byte contains CHAR_BIT bits, and the implementation chooses the exact widths and ranges of most fundamental types. Inspect them with sizeof, <limits.h>, and, when an exact-width interface matters, <stdint.h>.
Plain char, signed char, and unsigned char are three distinct types. The implementation decides whether plain char has the same range and behaviour as signed or unsigned char.
Rapid model answers:
Is
intalways 4 bytes? No. Check the implementation.Is
charalways signed? No. Plaincharsignedness is implementation-defined.What is
sizeof('A')in C? It issizeof(int), because an ordinary character constant such as'A'has typeint. The result is not guaranteed to be 4.
Use this inspection pattern:
printf("%zu\n", sizeof(int));The result of sizeof has type size_t, and %zu is the matching printf conversion. The C Language course provides a deeper route through these rules and their practice questions.
Fully worked example: integer promotion first, narrowing later

Assume CHAR_BIT = 8, UCHAR_MAX = 255, sizeof(int) = 4, and that int can represent 260. Now trace this code without skipping the expression types:
unsigned char u = 250;
int delta = 10;
int total = u + delta;
unsigned char stored = u + delta;
printf("%d %u\n", total, (unsigned)stored);ustarts as anunsigned charwith value 250. Becauseintcan represent every value from 0 through 255 in this environment, integer promotion convertsutointwith value 250.deltais already anintwith value 10. The addition is thereforeint 250 + int 10, which produces theintvalue 260.totalreceives that value unchanged, sototalis 260.The second addition also produces
intvalue 260. Assigning it to the 8-bitunsigned char storedconverts it moduloUCHAR_MAX + 1. Therefore,260 mod 256 = 4.
The exact output under the stated assumptions is:
260 4Interview follow-up: Did unsigned overflow occur during u + delta? No. The addition happened in int. The modulo conversion occurred later, when 260 was stored in unsigned char.

Floating-point questions: literals, division, and precision
float, double, and long double are distinct real floating types. double provides at least as much precision as float, and long double provides at least as much as double, but their exact sizes and representations are implementation-specific.
Literal suffixes determine type: 3.14 is double, 3.14f is float, and 3.14L is long double.
For division, operand types control the operator:
5 / 2performs integer division and produces2.5 / 2.0converts the left operand todoubleand produces2.5.
Even double result = 5 / 2; stores 2.0, because the integer division finished before assignment.
Binary floating-point values should often be compared with a tolerance:
double actual = 0.1 + 0.2;
double expected = 0.3;
if (fabs(actual - expected) < 1e-12) {
/* close enough for this example */
}Here 1e-12 suits this small illustration. It is not a universal tolerance. Choose one according to the problem's magnitude and error model.
Type-selection questions that reveal engineering judgement
Good type selection communicates the domain and matches the surrounding interface.
Scenario | Suitable type | Reason |
|---|---|---|
Buffer length |
| It is the type returned by |
Protocol field holding exactly 32 unsigned bits and |
| Use it when the implementation provides that exact-width type. Initialise with |
Pointer difference of |
| It represents signed differences between pointers into the same array. |
True or false state |
| It expresses a logical state without inventing an unrelated numeric domain. |
Model interview answer: Do not use int everywhere. Choose a type that communicates the value's domain, covers its required range, matches library interfaces, and preserves an external format when exact width is part of the contract.
Fixed-width types are valuable for exact-width protocols and file formats. They are not an automatic replacement for every loop counter or ordinary integer.
Four data-type traps interviewers use in output questions
Consider this comparison:
int i = -1;
unsigned int n = 1U;
printf("%d\n", i < n);The output is 0. The usual arithmetic conversions change i to unsigned int. Converting -1 produces UINT_MAX, which is not less than 1U.
Do not confuse this defined conversion with signed overflow. Signed integer overflow has undefined behaviour. Unsigned arithmetic is defined modulo one more than the type's maximum value.
Snippet | Correct result or status | Why |
|---|---|---|
|
|
|
| Not valid standard C |
|
| Not valid standard C | Standard pointer arithmetic needs a pointed-to object type with a defined size. |
| Undefined behaviour |
|
Is plain | Implementation-defined | A compiler may give plain |
Some compilers accept sizeof(void) or arithmetic on void * as extensions. That does not make those expressions portable C. Test these distinctions with about 40 Data Type Fundamentals MCQs and Solved Questions.
The short version for service and product interviews
Interview patterns vary. Screening rounds often begin with definitions, sizes, format specifiers, and short output snippets. Deeper technical rounds are more likely to probe portability, conversions, undefined behaviour, and why a type fits an API or data contract.
Use this four-step answer template:
State the C language rule.
Name any implementation assumption.
Trace each operand's type and value.
Finish with the portability or engineering implication.
For the worked example, that becomes: u promotes to int, 250 + 10 produces int value 260, and only the later assignment converts 260 modulo 256 to 4.
Never assume fixed widths, track promotions before arithmetic, distinguish signed and unsigned rules, and match every type with its format specifier. Continue with Coding for Placement for structured practice, then use the Resume and Interview preparation section for broader interview guidance.
Keep learning
Data Types in C Explained: Ranges, Conversions and Worked Exam Examples
Learn how C types control ranges and conversions, then apply the rules to overflow, mixed arithmetic, sizeof and signed-unsigned exam questions.
Python Data Types Explained: Concepts, Conversions and Exam-Style Output Tracing
Learn how Python names, objects and built-in types work, then trace conversions, division, list aliasing and shallow copying through an exact program.
Variables and Data Types in C: Declarations, Conversions and Runnable Examples
Learn how C types control stored values, expressions and I/O. Compile a complete marks program, trace its conversions and repair common type mistakes.
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.





