What is the size of an integer variable in most modern C compilers?
A2 bytes
B4 bytes
C8 bytes
DIt depends on the compiler
Correct Answer:
B. 4 bytes
Explanation:
On most modern 32-bit and 64-bit systems, an int is typically 4 bytes (32 bits). However, the exact size can vary depending on the compiler and system architecture.
Which of the following is NOT a valid C data type?
Afloat
Bboolean
Cdouble
Dchar
Correct Answer:
B. boolean
Explanation:
C does not have a built-in boolean data type. The other options (float, double, char) are all valid primitive data types in C. Boolean functionality is typically implemented using int (0 for false, non-zero for true).
The & operator has two uses in C: (1) When used before a variable, it returns the memory address of that variable (address-of operator), and (2) When used between two integers, it performs a bitwise AND operation.
Which keyword is used to create a constant variable in C?
Afinal
Bconstant
Cconst
Dstatic
Correct Answer:
C. const
Explanation:
The const keyword is used in C to declare a constant variable whose value cannot be modified after initialization. Variables declared as const are read-only.
What will be the memory size of the following struct?
struct Point { int x; char c; int y; }
A9 bytes
B10 bytes
C12 bytes
D16 bytes
Correct Answer:
C. 12 bytes
Explanation:
Due to memory alignment/padding: int x (4 bytes), char c (1 byte) + 3 bytes padding, int y (4 bytes) = 12 bytes total. The compiler adds padding to align data members to their natural boundaries for efficient memory access.