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 871–880 of 1,000
Topics in C Programming
Which keyword prevents a local variable from being optimized by compiler into a register?
A volatile
B static
C const
D restrict
Correct Answer:  A. volatile
EXPLANATION

volatile tells compiler that a variable's value may change unexpectedly and should not be optimized. It's often used for hardware registers.

Take Test
What is the difference between 'signed' and 'unsigned' char in terms of range?
A No difference
B signed: -128 to 127, unsigned: 0 to 255
C signed: 0 to 127, unsigned: -128 to 255
D signed: 0 to 256, unsigned: -128 to 128
Correct Answer:  B. signed: -128 to 127, unsigned: 0 to 255
EXPLANATION

Signed char uses 1 bit for sign, giving -128 to 127. Unsigned char uses all 8 bits for magnitude, giving 0 to 255.

Take Test
Which of the following demonstrates proper type casting in C?
A (int) 5.7
B int(5.7)
C int
D 5.7 as int
Correct Answer:  A. (int) 5.7
EXPLANATION

C uses C-style casting with parentheses: (type) expression. This converts 5.7 to integer 5.

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

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

Take Test
What will be the result of sizeof(int) on a typical 32-bit system?
A 2 bytes
B 4 bytes
C 8 bytes
D Undefined
Correct Answer:  B. 4 bytes
EXPLANATION

On 32-bit systems, int is typically 4 bytes (32 bits). However, the exact size is implementation-defined per C standard.

Take Test
Which of the following variable names is INVALID in C?
A _myVar
B myVar123
C 123myVar
D my_Var
Correct Answer:  C. 123myVar
EXPLANATION

Variable names cannot start with a digit in C. Valid names must begin with a letter (a-z, A-Z) or underscore (_).

Take Test
What is the size of the double data type in most 64-bit systems?
A 4 bytes
B 8 bytes
C 16 bytes
D Compiler dependent, no fixed size
Correct Answer:  B. 8 bytes
EXPLANATION

In standard C on 64-bit systems, double occupies 8 bytes and can store values with approximately 15-17 significant digits.

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

Take Test
Which keyword is used to modify a variable so that it cannot be changed?
A static
B const
C register
D extern
Correct Answer:  B. const
EXPLANATION

The const keyword makes a variable read-only after initialization. Its value cannot be modified during program execution.

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