Data Types in C Programming MCQ Questions and Answers
1. Which C data type is used to represent a single character?
A) int
B) char
C) float
D) short
[Answer: B]
2. Which operator returns the size (in bytes) of a data type or variable?
A) &
B) *
C) sizeof
D) typeid
[Answer: C]
3. Which of these is not a standard integer type in C?
A) long
B) medium
C) short
D) unsigned
[Answer: B]
4. Which qualifier makes an integer type able to store only non-negative values?
A) volatile
B) signed
C) unsigned
D) const
[Answer: C]
5. What is the default signedness of the plain char type in C?
A) Always signed
B) Always unsigned
C) Implementation-defined (either signed or unsigned)
D) Depends on compiler flag -signed
[Answer: C]
6. Which data type would you choose for high-precision real number computations?
A) float
B) double
C) short
D) char
[Answer: B]
7. Which format specifier prints a long int in printf?
A) %d
B) %ld
C) %f
D) %u
[Answer: B]
8. Which of the following describes typedef?
A) Changes memory layout of a type
B) Creates a type alias
C) Converts value types at runtime
D) Declares a constant
[Answer: B]
9. Which type is returned by the sizeof operator?
A) int
B) size_t
C) long
D) unsigned int
[Answer: B]
10. Which of these is not a floating-point type in C?
A) float
B) double
C) real
D) long double
[Answer: C]
11. What is the primary purpose of the const qualifier on a variable type?
A) Reduce memory footprint
B) Prevent modification of that variable
C) Force unsigned interpretation
D) Increase performance automatically
[Answer: B]
12. Which of the following is an example of integer promotion?
A) Assigning a float to a double
B) Converting char to int when used in arithmetic
C) Casting double to float explicitly
D) Assigning an int to a short
[Answer: B]
13. What is the C standard type suitable for storing pointer differences?
A) int
B) ptrdiff_t
C) size_t
D) long long
[Answer: B]
14. Which keyword indicates a function returns no value and has no type?
A) void
B) null
C) empty
D) none
[Answer: A]
15. Which of these is true about enum in C?
A) It is a distinct floating type
B) Enum constants are of integer type
C) Enum variables require 8 bytes always
D) Enum values must be strings
[Answer: B]
16. Which qualifier should you use when a variable may change at any time (e.g., hardware register)?
A) static
B) volatile
C) restrict
D) auto
[Answer: B]
17. Which type qualifier hints to the compiler that a pointer is the only means to access the object?
A) const
B) volatile
C) restrict
D) static
[Answer: C]
18. Which type would typically be used to store the return value of malloc (before casting)?
A) int
B) void*
C) char*
D) double
[Answer: B]
19. What happens on assigning a negative integer to an unsigned int?
A) Compile-time error
B) Runtime exception
C) Value is converted modulo 2^n (wrap-around)
D) Value becomes zero
[Answer: C]
20. Which of the following best describes a bit-field in a struct?
A) A pointer to bit memory
B) A member that uses specified number of bits
C) A field aligned to byte boundaries only
D) A macro for boolean types
[Answer: B]
21. Which type would be most appropriate for indexing array elements portably?
A) double
B) size_t
C) short
D) signed char
[Answer: B]
22. Which conversion is performed implicitly when you mix int and double in an expression?
A) double converted to int
B) int promoted to double
C) both converted to float
D) both converted to long double
[Answer: B]
23. Which of the following is true about long double compared with double?
A) Always smaller than double
B) At least as precise as double (commonly more)
C) Has the same precision on all implementations
D) Is an integer type
[Answer: B]
24. The short type is guaranteed to be at least how many bits by the C standard?
A) 8 bits
B) 16 bits
C) 32 bits
D) 64 bits
[Answer: B]
25. Which statement about signed vs unsigned left-shift behavior is correct?
A) Left-shifting a signed negative value is undefined behavior in C.
B) Left-shift treats signed and unsigned the same always.
C) Left-shift is always arithmetic for unsigned types only.
D) Shifting signed values is always safe.
[Answer: A]
26. Which of these is the correct printf specifier for unsigned long long?
A) %llu
B) %ulll
C) %d
D) %lf
[Answer: A]
27. Which C type is most suitable for representing boolean values before <stdbool.h> existed?
A) int (0 false, non-zero true)
B) char
C) float
D) struct bool_t
[Answer: A]
28. What is the effect of short int x = 32768; on systems where short is 16-bit?
A) Assigns 32768 correctly
B) Truncation/overflow — implementation-defined or wrap-around
C) Compile-time error
D) Promotes to int automatically
[Answer: B]
29. Which type conversion uses explicit cast?
A) Implicit conversion from int to float in expression
B) (double) x
C) Integer promotion of char
D) Default argument promotions
[Answer: B]
30. What does float f = 1.0/3; typically store?
A) Exact rational 1/3
B) A rounded approximation within float precision
C) Integer 0
D) Compile-time error
[Answer: B]
31. Which of the following types can union members share?
A) Memory location overlapped — only one active at time
B) All members are stored separately
C) Unions are only for integers
D) Union enforces alignment to 64 bits always
[Answer: A]
32. Which statement about sizeof(char) is correct?
A) It can be 2 on some compilers
B) It is always 1 by definition (one byte unit)
C) It’s equal to sizeof(int)
D) It depends on signedness
[Answer: B]
33. Which type do character literals like ‘A’ have in C?
A) char
B) int
C) unsigned char
D) short
[Answer: B]
34. When assigning a double to a float, what can occur?
A) Precision loss (narrowing conversion)
B) No change ever
C) Compile-time failure always
D) Value doubles in magnitude
[Answer: A]
35. Which of these is a standard header for fixed-width integer types like int32_t?
A) <stdint.h>
B) <limits.h>
C) <float.h>
D) <ctype.h>
[Answer: A]
36. Which macro gives the maximum value representable by an int?
A) INT_MAX
B) MAX_INT
C) INTMAX
D) INTEGER_MAX
[Answer: A]
37. Which constant type does a numeric literal 10U represent?
A) signed int
B) unsigned int
C) long int
D) float
[Answer: B]
38. What is the type of string literal “hello” in C?
A) char*
B) const char[] (array of char stored in static storage)
C) int
D) void*
[Answer: B]
39. Which of these is true about float arithmetic compared to exact math?
A) Float arithmetic is associative for addition always
B) Float arithmetic can have rounding error and is not strictly associative
C) Floats never lose precision
D) Float uses arbitrary precision
[Answer: B]
40. Which type qualifier tells the compiler a value cannot be changed through this identifier?
A) volatile
B) const
C) static
D) auto
[Answer: B]
41. What is the principal reason to use unsigned types?
A) To speed up floating operations
B) To increase precision of signed fractions
C) To represent non-negative quantities with clearer semantics
D) To allow negative indexes
[Answer: C]
42. Which C header defines size_t?
A) <stddef.h>
B) <stdio.h>
C) <stdlib.h>
D) <string.h>
[Answer: A]
43. What is the correct way to declare a pointer to a function returning int and taking two floats?
A) int *f(float, float);
B) int (f)(float, float);
C) int f(float, float);
D) int (*f)*float;
[Answer: B]
44. Which of these best describes implementation-defined behavior?
A) Behavior the standard forbids
B) Behavior the implementation documents and must choose consistently
C) Behavior that is random at runtime
D) Behavior that leads to immediate crash
[Answer: B]
45. Which of the following is true about long long?
A) It is guaranteed to be at least 64 bits by the C standard (since C99).
B) It is identical to int always.
C) It cannot be signed.
D) It stores floating point numbers.
[Answer: A]
46. Which header contains limits for floating types like FLT_MAX?
A) <limits.h>
B) <float.h>
C) <stdint.h>
D) <math.h>
[Answer: B]
47. When you write int x = 5.7; what happens?
A) x becomes 5 (fraction truncated)
B) x becomes 6 (rounded)
C) Compile error
D) x becomes 5.7 as double
[Answer: A]
48. Which of the following best describes signed char and char?
A) signed char and char are always the same type
B) signed char is explicitly signed; char may be signed or unsigned (implementation-defined)
C) char is always unsigned
D) char is a floating type
[Answer: B]
49. Which type is recommended for file sizes and memory buffer sizes?
A) size_t
B) int
C) char
D) float
[Answer: A]
50. What happens if you mix unsigned int and int in an expression where int is negative?
A) The negative int is converted to unsigned — may yield large value
B) The expression fails to compile
C) Negative is preserved in result as negative signed value
D) The compiler issues runtime error automatically
[Answer: A]
51. In printf, which specifier prints a double?
A) %f
B) %d
C) %ld
D) %c
[Answer: A]
52. Which of the following is a correct statement about float and double literals?
A) 3.14 is a double literal by default.
B) 3.14f is a double literal by default.
C) 3.14L is a float literal.
D) 3 is always float.
[Answer: A]
53. Which type should you use to store extremely large integral counts portably?
A) long long or intmax_t
B) char
C) float
D) short
[Answer: A]
54. Which of the following indicates an integer constant with long type?
A) 10L
B) 10.0L
C) 10f
D) 10u
[Answer: A]
55. Which of these best explains “narrowing” conversion?
A) Converting from smaller to larger type without data loss
B) Converting from larger type to smaller type that may lose information
C) Converting pointer to integer
D) Converting array to pointer
[Answer: B]
56. What is the typical use of int8_t?
A) To represent an 8-bit signed integer explicitly (when available)
B) Floating point arithmetic
C) To store pointer addresses
D) To store Unicode code points only
[Answer: A]
57. Which C keyword gives internal linkage to a global variable?
A) extern
B) static
C) auto
D) register
[Answer: B]
58. Which of the following describes register keyword today?
A) It forces register placement reliably on modern compilers
B) It is a hint only and largely ignored by modern compilers; deprecated in C11
C) It makes variable global
D) It converts type to unsigned
[Answer: B]
59. Which of these statements is true about integer overflow for signed types?
A) Signed integer overflow is undefined behavior in C
B) Signed integer overflow wraps around modulo 2^n always
C) Signed integer overflow raises an exception automatically
D) Signed integer types cannot overflow
[Answer: A]
60. What is the conversion rank concept used for in C?
A) Determining evaluation order in loops
B) Determining which integer type has higher conversion priority during usual arithmetic conversions
C) Ranking pointer sizes
D) Sorting arrays
[Answer: B]
61. Which type should be used to ensure at least 16 bits of storage?
A) short (guaranteed at least 16 bits)
B) char (guaranteed at least 16 bits)
C) int8_t
D) float
[Answer: A]
62. What does INT_MIN represent?
A) Minimum value of an integer type on that implementation
B) Maximum value of an integer type
C) Minimum index of arrays
D) Minimum of floats
[Answer: A]
63. Which is true about implicit conversions in function calls with variadic functions (…)?
A) Default argument promotions apply: float becomes double, char/short promoted to int
B) No promotions occur
C) Doubles become floats
D) Pointers are converted to integers automatically
[Answer: A]
64. Which of these types can be used for bitwise operations most naturally?
A) Integer types (signed or unsigned)
B) float/double
C) void
D) enum only
[Answer: A]
65. Which of the following is true about char16_t and char32_t in C?
A) They are provided by C11/C++11 for Unicode code units (if available)
B) They are standard since C89
C) They are synonymous with char always
D) They store decimal fractions
[Answer: A]
66. What does long mean when used as long double?
A) A floating type that is at least as wide as double, often wider
B) Same as int
C) Integer type
D) A macro
[Answer: A]
67. Which choice correctly declares a constant pointer to int (pointer itself constant)?
A) int * const p;
B) const int * p;
C) int const * p;
D) const int const * p;
[Answer: A]
68. Which of these declares a pointer to a constant int (pointed value cannot be changed)?
A) const int * p;
B) int * const p;
C) int const * const p;
D) int * p;
[Answer: A]
69. Which type allows representation of the greatest width signed integer guaranteed by implementation?
A) intmax_t
B) long double
C) size_t
D) float
[Answer: A]
70. When mixing float and double operands, what does usual arithmetic conversion do?
A) Promote float to double
B) Demote double to float
C) Convert both to long double always
D) Convert both to int
[Answer: A]
71. Which specifier prints a size_t in printf portably?
A) %zu
B) %d
C) %lu always
D) %f
[Answer: A]
72. What does volatile const imply about a variable?
A) It can change outside program control but cannot be modified by program code
B) It is both modifiable and immutable simultaneously
C) It is undefined
D) It is stored in register only
[Answer: A]
73. Which of these is true about pointer-to-void void *?
A) It is a generic pointer type that can be converted to/from other object pointer types
B) It can be dereferenced directly
C) It stores function pointers only
D) It holds integers only
[Answer: A]
74. Which type is typically used to hold wide characters (locale-dependent)?
A) wchar_t
B) char
C) int
D) float
[Answer: A]
75. If an enum is not explicitly assigned values, what values do its members get?
A) Sequential integers starting at 0 by default
B) Random values
C) All zeros only
D) Negative values only
[Answer: A]
76. Which of the following best describes the fmod function behavior vs integer modulus?
A) fmod exists for floating-point remainder; integer % is for integers only
B) fmod is identical to % always
C) % can be used on doubles
D) fmod returns integer results only
[Answer: A]
77. Which C type cannot be dereferenced?
A) void (as in void value)
B) int*
C) char*
D) double*
[Answer: A]
78. Which of the following is a correct cast from void* to int*?
A) (int*) ptr
B) (int) ptr
C) (void) ptr
D) No cast is allowed in C
[Answer: A]
79. Which of these standard headers defines intptr_t and uintptr_t?
A) <stdint.h>
B) <stdlib.h>
C) <stdio.h>
D) <limits.h>
[Answer: A]
80. What is true about default initialization of local non-static variables in C?
A) They have indeterminate values (not automatically zeroed)
B) They are always zero-initialized
C) They are initialized to 1 by default
D) Compiler forces initialization to debug pattern always
[Answer: A]
81. Which of these represents a safe way to check for overflow when adding two unsigned values a and b?
A) Check if a > UINT_MAX – b before addition
B) Use try/catch for overflow
C) Signed overflow rules apply
D) There is no method
[Answer: A]
82. Which type modifier affects a floating-point literal such as 3.14F?
A) Makes it float rather than double
B) Makes it int
C) Makes it long
D) Makes it char
[Answer: A]
83. Which of the following is safe to use for bit-field width specification?
A) Integer constant expression (e.g., unsigned int x:5;)
B) Floating expression
C) Non-constant variable
D) Pointer type
[Answer: A]
84. What is the role of <limits.h> in C?
A) Defines macros for sizes and limits of integer types (e.g., INT_MAX)
B) Provides math functions
C) Declares I/O functions
D) Defines floating constants only
[Answer: A]
85. Which of these must be true for two types to be compatible in assignments without cast?
A) They must be the same type or compatible type as per standard (e.g., signedness and size match)
B) They must have the same name only
C) They must both be pointers to any type
D) Any numeric types are always compatible
[Answer: A]
86. Which of these is the correct reason to use int_fast16_t from <stdint.h>?
A) It gives at least 16-bit width but optimized for speed on platform
B) It is always 16 bits exactly
C) It is a floating type
D) It is deprecated
[Answer: A]
87. Which of the following statements about char arrays containing strings is correct?
A) They allocate space for characters including terminating \0
B) \0 is optional for proper string handling in C library functions
C) Strings in C are objects of type int
D) String literals are mutable always
[Answer: A]
88. Which operation is undefined for pointers?
A) Subtracting pointers to different arrays (except computing difference is undefined behavior)
B) Adding integer to pointer within same array is defined
C) Comparing pointers within same array is defined
D) Subtracting pointers within the same array yields difference in elements
[Answer: A]
89. Which of these is true about float precision?
A) float typically has 24 bits of significand precision (about 6-9 decimal digits) in IEEE-754 single precision
B) float has more precision than double always
C) float stores exact rational numbers always
D) float uses base-10 internally
[Answer: A]
90. Which specifier prints a long double in printf?
A) %Lf
B) %lf
C) %f
D) %Ld is correct for long doubles?
[Answer: A]
91. Which header defines NULL in C?
A) <stddef.h> or <stdio.h> or <stdlib.h> (multiple headers)
B) Only <stdio.h>
C) Only <math.h>
D) It is a compiler intrinsic only
[Answer: A]
92. Which of these is true about floating-point NaN in IEEE-754?
A) NaN is not equal to any value, including itself
B) NaN equals itself always
C) NaN behaves exactly like zero
D) C standard prohibits NaN
[Answer: A]
93. Which type conversion is lossless when converting from int32_t to int64_t?
A) Widening conversion to larger signed type preserves value (if representable) — here it’s lossless
B) It always loses precision
C) Converts to float automatically
D) Makes it unsigned
[Answer: A]
94. Which function returns the next representable floating-point value (successor) in C99/C11?
A) nextafter or nexttoward family in <math.h>
B) nextfloat in <float.h>
C) increment in <stdlib.h>
D) There is no function ever
[Answer: A]
95. Which of the following about signed and unsigned comparison is correct?
A) When comparing signed to unsigned, the signed is converted to unsigned first (if types differ) — can produce unexpected results.
B) Signed is always compared as signed regardless of unsigned presence.
C) Unsigned is always converted to signed first.
D) Compiler warns and uses signed comparison.
[Answer: A]
96. What is FLT_EPSILON used for?
A) Represents the difference between 1 and the least value greater than 1 representable for float (machine epsilon)
B) Maximum float value
C) Minimum float value always negative
D) Float exception mask
[Answer: A]
97. Which of these is true about aggregate initialization for arrays of basic types?
A) Missing elements are zero-initialized
B) Missing elements contain garbage always
C) Compiler errors out if not all elements initialized
D) Missing elements are initialized to 1
[Answer: A]
98. Which type should be used to portably store the result of sizeof?
A) size_t
B) int
C) long long
D) char
[Answer: A]
99. Which of these is a correct observation about pointer-to-function types?
A) Function pointers are distinct from object pointers (void* cannot portably hold function pointer)
B) Function pointers are the same as void* always
C) Function pointers can be dereferenced as data
D) Function pointers are integers always
[Answer: A]
100. Which of the following is the correct behavior when converting integer to pointer types in C (without cast)?
A) You must use an explicit cast to convert integer to pointer; otherwise it’s a constraint violation or implementation-defined if using large integer constants — explicit cast required for clarity.
B) Implicit conversion always allowed
C) Compiler always errors
D) Compiler converts to void automatically
[Answer: A]
