Home Subjects C Programming

C Programming

C language from basics to advanced placement prep

291 Q 10 Topics Take Mock Test
Advertisement
Difficulty: All Easy Medium Hard 251–260 of 291
Topics in C Programming
What is the scope of a variable declared inside a function block?
A Global scope
B File scope
C Block scope (local)
D Function scope
Correct Answer:  C. Block scope (local)
EXPLANATION

Variables declared inside a block (including function blocks) have block scope and are accessible only within that block.

Test
What is the range of unsigned char in C?
A 0 to 127
B 0 to 255
C -128 to 127
D -256 to 255
Correct Answer:  B. 0 to 255
EXPLANATION

unsigned char is 1 byte (8 bits) without sign bit, giving range 0 to 2^8-1 = 0 to 255.

Test
What is the default data type of a floating-point constant in C?
A float
B double
C long double
D It depends on the compiler
Correct Answer:  B. double
EXPLANATION

In C, floating-point constants like 3.14 are treated as double by default. To specify float, you need to use 3.14f suffix.

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.

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 (_).

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.

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.

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

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.

Test
Which of the following is a derived data type in C?
A int
B Array
C char
D float
Correct Answer:  B. Array
EXPLANATION

Derived data types are created from fundamental types. Arrays, pointers, structures, and unions are derived types.

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