Which of the following is NOT a fundamental data type in C?
Answer: C
C has 5 fundamental data types: int, float, double, char, and void. 'string' is not a fundamental type; it's created using char arrays.
Q.2Easy
What is the size of an 'int' variable in a 32-bit system?
Answer: B
In a 32-bit system, an int is typically 4 bytes (32 bits). However, the C standard only guarantees it's at least 2 bytes, so technically it's compiler-dependent. But in practice, 4 bytes is standard.
Q.3Easy
Which variable declaration is correct in C?
Answer: C
Variable names must start with a letter or underscore, followed by letters, digits, or underscores. Option C follows this rule correctly.
Q.4Medium
What will be the output of the following code?
int x = 5;
float y = x;
printf("%f", y);
Answer: A
Implicit type conversion occurs from int to float. The value 5 is converted to 5.0 and printed as 5.000000 with %f format specifier.
Q.5Medium
Which of the following occupies maximum memory in a 64-bit system?
Answer: B
In a 64-bit system, long double typically occupies 16 bytes (128 bits), which is the maximum among these options.
Advertisement
Q.6Medium
What is the range of unsigned int in a 32-bit system?
Answer: B
Unsigned int uses all 32 bits for magnitude, giving range 0 to 2^32 - 1 (0 to 4,294,967,295).
Q.7Easy
Which keyword is used to declare a variable that cannot be modified?
Answer: B
'const' keyword makes a variable constant and immutable after initialization.
Q.8Medium
What is the difference between 'static' and 'extern' variables?
Answer: B
static restricts variable visibility to the current file; extern declares a variable defined elsewhere with global scope.
Q.9Medium
What is the output of the following code?
int x = 10;
int *p = &x;
printf("%d", *p);
Answer: A
p is a pointer to x. *p dereferences the pointer, giving the value of x, which is 10.
Q.10Easy
Which of the following is a derived data type in C?
Answer: B
Derived data types are created from fundamental types. Arrays, pointers, structures, and unions are derived types.
Q.11Hard
What will be the size of the following structure?
struct test {
char c;
int i;
float f;
};
Answer: D
Size depends on compiler's padding and alignment rules. Typically 12 bytes with padding, but varies by system.
Q.12Medium
Which variable storage class has default initialization to 0?
Answer: C
Static variables are automatically initialized to 0 by the compiler.
Q.13Medium
What is the output of this code?
float x = 25;
printf("%f", x);
Answer: B
25 performs integer division (both operands are int), resulting in 2. This is then converted to float as 2.0.
Q.14Easy
How many bits are used to store a 'short int' in a standard C environment?
Answer: B
Standard C guarantees short int is at least 16 bits (2 bytes). Most systems use exactly 16 bits.
Q.15Medium
What happens when you declare a variable without initializing it?
Answer: B
Auto variables (local variables) contain unpredictable garbage values if not initialized. Static/global variables are initialized to 0.
Q.16Hard
Which of the following correctly demonstrates pointer arithmetic?
Answer: A
Option A shows pointer arithmetic where p++ increments the pointer by the size of int (4 bytes). Other options are regular arithmetic operations.
Q.17Hard
What is the output of the following code?
int a = 5;
int *p = &a;
int q = &p;
printf("%d", q);
Answer: A
q is a pointer to pointer p. **q dereferences both pointers, giving the value of a, which is 5.
Q.18Medium
Which data type is most suitable for storing a decimal number with high precision?
Answer: C
long double provides maximum precision (typically 80-128 bits) for decimal numbers compared to float (32 bits) and double (64 bits).
Q.19Easy
What is the range of values for a signed char in C?
Answer: B
A signed char occupies 1 byte (8 bits). With sign bit, it ranges from -128 to 127 (2^7 to 2^7-1).
Q.20Easy
Which keyword is used to modify a variable so that it cannot be changed?
Answer: B
The const keyword makes a variable read-only after initialization. Its value cannot be modified during program execution.