What will be the output: const int x = 10; x = 20; printf("%d", x);
Answer: C
const variables cannot be modified after initialization. Attempting to assign a new value causes a compilation error.
Q.82Medium
Which of these correctly represents a floating-point literal with exponent notation?
Answer: A
Correct exponent notation requires a digit before and after 'e'. 1.5e2 represents 1.5 × 10² = 150.0
Q.83Medium
What is the range of values for a signed short int?
Answer: B
Signed short int is typically 2 bytes (16 bits), providing a range from -2^15 to 2^15-1.
Q.84Hard
What is the primary purpose of the 'restrict' keyword introduced in C99?
Answer: B
The 'restrict' qualifier tells the compiler that a pointer is the only way to access that object, enabling optimizations.
Q.85Hard
What happens in this code: int arr[5]; int *p = &arr[0]; printf("%d", sizeof(p));
Answer: B
p is a pointer variable, so sizeof(p) returns the size of the pointer itself (4 bytes on 32-bit, 8 bytes on 64-bit systems), not the array.
Advertisement
Q.86Medium
Which of the following is a valid declaration of a constant array?
Answer: D
Both declarations make the array elements constant. Option A initializes the array, while B declares it without initialization (valid at global scope).
Q.87Easy
In C programming, which of the following is NOT a fundamental data type?
Answer: C
string is not a fundamental data type in C. Fundamental types are int, float, double, char, and void. Strings are arrays of characters.
Q.88Easy
What is the size of a 'long long int' variable in C on a 64-bit system?
Answer: B
A 'long long int' is guaranteed to be at least 64 bits (8 bytes) by the C99 standard on all systems including 64-bit architectures.
Q.89Easy
Which keyword is used to declare a variable that cannot be modified after initialization?
Answer: C
The 'const' keyword declares a constant variable whose value cannot be modified after initialization. Attempting to modify it results in a compile-time error.
Q.90Easy
Which of the following variable declarations will occupy the LEAST memory?
Answer: C
char data type typically occupies 1 byte, which is the minimum. int is 4 bytes, float is 4 bytes, and double is 8 bytes on most systems.
Q.91Medium
In C, what is the difference between 'int' and 'unsigned int' in terms of range on a 32-bit system?
Answer: B
signed int reserves 1 bit for sign, giving range -2147483648 to 2147483647. unsigned int uses all 32 bits for magnitude, giving 0 to 4294967295.
Q.92Hard
What will be the result of the following expression:
float x = 0.1 + 0.2;
if(x == 0.3) printf("Equal"); else printf("Not Equal");
Answer: B
Due to floating-point precision limitations, 0.1 + 0.2 does not exactly equal 0.3 in binary representation. Direct comparison with == fails.
Q.93Medium
Which storage class has both 'static' and 'auto' properties in certain contexts?
Answer: A
register requests compiler to store variable in CPU register for faster access but falls back to memory if unavailable, combining automatic allocation with optimization hints.
Q.94Medium
What is the output of:
int arr[3] = {1, 2, 3};
int *p = arr;
printf("%d %d", *p, *(p+2));
Answer: A
p points to arr[0] which is 1. p+2 points to arr[2] which is 3. Therefore output is '1 3'.
Q.95Medium
Consider a scenario where you need to store a variable that can hold values up to 10 billion. Which data type is most suitable?
Answer: C
int max is ~2.1 billion, long int varies (may be 32 or 64 bits). long long int guarantees 64 bits with max ~9.2 quintillion, sufficient for 10 billion.
Q.96Hard
What happens when a volatile variable is declared in a multi-threaded C program?
Answer: B
volatile tells compiler not to optimize variable accesses and to fetch fresh value from memory, useful for hardware registers and shared memory, but doesn't guarantee thread-safety without synchronization.
Q.97Easy
In C programming, when you declare a variable as 'const int x = 5;', what happens if you try to modify it within the program?
Answer: B
The 'const' keyword creates a read-only variable. Once initialized, attempting to modify a const variable results in a compilation error (error: assignment of read-only variable). This is enforced at compile-time, not runtime.