Home Subjects C Programming Data Types & Variables

C Programming
Data Types & Variables

C language from basics to advanced placement prep

28 Q 10 Topics Take Mock Test
Advertisement
Difficulty: All Easy Medium Hard 21–28 of 28
Topics in C Programming
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
Which keyword is used to declare a variable that cannot be modified?
A static
B const
C volatile
D extern
Correct Answer:  B. const
EXPLANATION

'const' keyword makes a variable constant and immutable after initialization.

Test
Which variable declaration is correct in C?
A int 2var;
B float var-name;
C char _var123;
D double var@name;
Correct Answer:  C. char _var123;
EXPLANATION

Variable names must start with a letter or underscore, followed by letters, digits, or underscores. Option C follows this rule correctly.

Test
What is the size of an 'int' variable in a 32-bit system?
A 2 bytes
B 4 bytes
C 8 bytes
D Compiler dependent
Correct Answer:  B. 4 bytes
EXPLANATION

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.

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

C has 5 fundamental data types: int, float, double, char, and void. 'string' is not a fundamental type; it's created using char arrays.

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