Home Subjects C Programming

C Programming

C language from basics to advanced placement prep

1,000 Q 10 Topics Take Test
Advertisement
Difficulty: All Easy Medium Hard 881–890 of 1,000
Topics in C Programming
What is the range of values for a signed char in C?
A 0 to 255
B -128 to 127
C -256 to 255
D -127 to 128
Correct Answer:  B. -128 to 127
EXPLANATION

A signed char occupies 1 byte (8 bits). With sign bit, it ranges from -128 to 127 (2^7 to 2^7-1).

Take 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).

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

q is a pointer to pointer p. **q dereferences both pointers, giving the value of a, which is 5.

Take Test
What is the purpose of the 'volatile' keyword in C?
A To prevent variable modification
B To tell compiler not to optimize access to a variable
C To allocate memory on stack
D To make variable globally accessible
Correct Answer:  B. To tell compiler not to optimize access to a variable
EXPLANATION

'volatile' tells the compiler that a variable's value may change unexpectedly (e.g., by hardware), preventing optimization.

Take Test
Which of the following correctly demonstrates pointer arithmetic?
A int *p; p++;
B int x = 5; x++;
C char c = 'a'; c = c + 1;
D float f = 3.14; f = f + 1;
Correct Answer:  A. int *p; p++;
EXPLANATION

Option A shows pointer arithmetic where p++ increments the pointer by the size of int (4 bytes). Other options are regular arithmetic operations.

Take 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.

Take Test
How many bits are used to store a 'short int' in a standard C environment?
A 8 bits
B 16 bits
C 32 bits
D Varies by compiler
Correct Answer:  B. 16 bits
EXPLANATION

Standard C guarantees short int is at least 16 bits (2 bytes). Most systems use exactly 16 bits.

Take 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.

Take 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.

Take Test
What will be the size of the following structure?
struct test {
char c;
int i;
float f;
};
A 9 bytes
B 12 bytes
C 13 bytes
D Depends on padding and alignment
Correct Answer:  D. Depends on padding and alignment
EXPLANATION

Size depends on compiler's padding and alignment rules. Typically 12 bytes with padding, but varies by system.

Take Test
IGET
iget AI
Online · Ask anything about exams
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