What is true about the variable declared as 'extern int count;' inside a function?
Answer: B
extern is a declaration (not definition) that tells compiler the variable exists elsewhere in program. It provides global scope.
Q.122Hard
Consider a structure with int (4 bytes), char (1 byte), and double (8 bytes). What is the minimum size due to alignment requirements?
Answer: C
Due to structure padding/alignment, the size becomes 24 bytes (8-byte alignment for double). Members are padded to maintain alignment.
Q.123Hard
Which of the following statements about type qualifiers is INCORRECT?
Answer: C
restrict prevents pointer aliasing (not allows). It tells compiler that pointer is the only way to access that object.
Q.124Easy
What is the default data type of a floating-point constant in C?
Answer: B
In C, floating-point constants like 3.14 are treated as double by default. To specify float, you need to use 3.14f suffix.
Q.125Medium
What is the size of int data type on a 32-bit system according to C standard?
Answer: C
The C standard guarantees int is at least 2 bytes, but most 32-bit systems use 4 bytes. The exact size is implementation-dependent.
Advertisement
Q.126Medium
In the declaration 'int arr[10], *ptr;', which statement is correct?
Answer: B
The declaration uses comma separation. 'int arr[10]' declares an array of 10 integers, while '*ptr' declares a pointer to int.
Q.127Medium
Which of the following correctly declares a constant integer variable?
Answer: C
Both 'const int' and 'int const' are valid and equivalent ways to declare a constant integer in C.
Q.128Easy
What is the range of unsigned char in C?
Answer: B
unsigned char is 1 byte (8 bits) without sign bit, giving range 0 to 2^8-1 = 0 to 255.
Q.129Medium
What happens when you assign a larger data type value to a smaller one?
Answer: B
C allows implicit type conversion. When assigning larger to smaller type, truncation or data loss may occur without any compiler error.
Q.130Hard
In the declaration 'volatile int x;', what does volatile signify?
Answer: A
volatile tells the compiler that the variable's value may change unexpectedly (e.g., by hardware, signals, or another thread), so the compiler should not optimize it.
Q.131Easy
What is the scope of a variable declared inside a function block?
Answer: C
Variables declared inside a block (including function blocks) have block scope and are accessible only within that block.
Q.132Easy
Which of the following is a storage class in C?
Answer: C
The storage classes in C are: auto, register, static, and extern. 'static' is one of them.
Q.133Medium
What is the output of: printf("%d", sizeof(int) + sizeof(char))?
Answer: C
# Understanding `sizeof()` Operator in C
The `sizeof()` operator returns the size of data types in bytes, which varies depending on the compiler and system architecture.
Step 1: Analyze sizeof(int)
In C, the size of `int` is implementation-defined and depends on the system architecture and compiler.
sizeof(int)=⎩⎨⎧2 bytes (16-bit systems)4 bytes (32-bit/64-bit systems)or other values
Step 2: Analyze sizeof(char) and Calculate Total
The `char` data type always occupies exactly 1 byte across all standard C implementations, but `int` varies by platform.
Result=sizeof(int)+sizeof(char)=sizeof(int)+1
For a 16-bit system: 2+1=3 bytes
For a 32-bit system: 4+1=5 bytes
For a 64-bit system: 4+1=5 bytes (typically)
The output depends on the system's architecture. The minimum guaranteed value is 3 bytes (on 16-bit systems), but it can be higher on modern systems.
Correct Answer: (C) Depends on system (at least 3)
Q.134Medium
What is the difference between 'char' and 'unsigned char' for character representation?
Answer: D
char (signed) has range -128 to 127, while unsigned char has 0 to 255. The latter can represent extended ASCII characters (128-255).
Q.135Medium
In C, what is the result of: int x = 5.7?
Answer: B
When assigning a double to int, C performs implicit type conversion with truncation (not rounding). The decimal part is discarded.
Q.136Easy
What is the difference between initialization and assignment in C?
Answer: B
Initialization assigns a value when the variable is declared (int x = 5;). Assignment changes the value later (x = 10;).
Q.137Medium
What will happen if you declare a variable without initializing it?
Answer: A
Uninitialized local variables contain garbage values (random data from memory). Static/global variables are initialized to 0 by default.
Q.138Medium
Which format specifier is used for printing a long integer?
Answer: B
%ld is for long int, %lld is for long long int, and %d is for regular int. Using wrong specifier can cause undefined behavior.
Q.139Hard
In the declaration 'int *p, q;', what are the data types?
Answer: B
The '*' applies only to the immediately following variable. So 'int *p' declares p as pointer to int, and 'q' is just an int.
Q.140Hard
What is the purpose of the 'restrict' keyword in modern C?
Answer: B
restrict (C99) informs the compiler that a pointer is the sole accessor to the object, enabling optimization. It doesn't prevent modification.