Home Subjects C Programming Data Types & Variables

C Programming
Data Types & Variables

C language from basics to advanced placement prep

52 Q 10 Topics Take Mock Test
Advertisement
Difficulty: All Easy Medium Hard 41–50 of 52
Topics in C Programming
Consider: long long int x; What is the minimum guaranteed size of x according to C standard?
A 4 bytes
B 8 bytes
C 16 bytes
D Compiler defined
Correct Answer:  B. 8 bytes
EXPLANATION

According to C99 standard, long long int is guaranteed to be at least 8 bytes (64 bits).

Test
Which storage class variable is automatically initialized to 0 if not explicitly initialized?
A auto
B register
C static
D extern
Correct Answer:  C. static
EXPLANATION

static variables are automatically initialized to 0 for numeric types and NULL for pointers if not explicitly initialized.

Test
In C, which storage class has the longest scope and lifetime?
A auto
B register
C static
D extern
Correct Answer:  D. extern
EXPLANATION

extern variables have global scope and exist throughout program execution. They can be accessed across multiple files.

Test
Which data type is most suitable for storing a decimal number with high precision?
A float
B double
C long double
D int
Correct Answer:  C. long double
EXPLANATION

long double provides maximum precision (typically 80-128 bits) for decimal numbers compared to float (32 bits) and double (64 bits).

Test
What happens when you declare a variable without initializing it?
A It's set to 0 automatically
B It contains garbage value (for auto variables)
C Compilation error occurs
D It's set to NULL
Correct Answer:  B. It contains garbage value (for auto variables)
EXPLANATION

Auto variables (local variables) contain unpredictable garbage values if not initialized. Static/global variables are initialized to 0.

Test
What is the output of this code?
float x = 5 / 2;
printf("%f", x);
A 2.500000
B 2.000000
C 5/2
D Compilation error
Correct Answer:  B. 2.000000
EXPLANATION

5/2 performs integer division (both operands are int), resulting in 2. This is then converted to float as 2.0.

Test
Which variable storage class has default initialization to 0?
A auto
B register
C static
D extern
Correct Answer:  C. static
EXPLANATION

Static variables are automatically initialized to 0 by the compiler.

Test
What is the output of the following code?
int x = 10;
int *p = &x;
printf("%d", *p);
A 10
B Address of x
C Garbage value
D Compilation error
Correct Answer:  A. 10
EXPLANATION

p is a pointer to x. *p dereferences the pointer, giving the value of x, which is 10.

Test
What is the difference between 'static' and 'extern' variables?
A static has global scope, extern has local scope
B static has file scope, extern has global scope
C No difference
D static is for functions, extern is for variables
Correct Answer:  B. static has file scope, extern has global scope
EXPLANATION

static restricts variable visibility to the current file; extern declares a variable defined elsewhere with global scope.

Test
What is the range of unsigned int in a 32-bit system?
A 0 to 2^31 - 1
B 0 to 2^32 - 1
C -2^31 to 2^31 - 1
D 0 to 2^16 - 1
Correct Answer:  B. 0 to 2^32 - 1
EXPLANATION

Unsigned int uses all 32 bits for magnitude, giving range 0 to 2^32 - 1 (0 to 4,294,967,295).

Test
IGET
IGET AI
Online · Exam prep assistant
Hi! 👋 I'm your iget AI assistant.

Ask me anything about exam prep, MCQ solutions, study tips, or strategies! 🎯
UPSC strategy SSC CGL syllabus Improve aptitude NEET Biology tips