Home Subjects C Programming Data Types & Variables

C Programming
Data Types & Variables

C language from basics to advanced placement prep

100 Q 10 Topics Take Test
Advertisement
Difficulty: All Easy Medium Hard 51–60 of 100
Topics in C Programming
What is the difference between 'char' and 'unsigned char' for character representation?
A No difference; they are aliases
B char can hold negative values; unsigned char cannot
C unsigned char can hold larger ASCII values (128-255)
D Both B and C are correct
Correct Answer:  D. Both B and C are correct
EXPLANATION

char (signed) has range -128 to 127, while unsigned char has 0 to 255. The latter can represent extended ASCII characters (128-255).

Take Test
What is the output of: printf("%d", sizeof(int) + sizeof(char))?
A 4
B 5
C Depends on system (at least 3)
D 8
Correct Answer:  C. Depends on system (at least 3)
EXPLANATION

sizeof(int) is typically 4 bytes and sizeof(char) is 1 byte, giving 5 on most systems. However, sizes are implementation-dependent (at least int=2, char=1).

Take Test
Which of the following is a storage class in C?
A primary
B secondary
C static
D dynamic
Correct Answer:  C. static
EXPLANATION

The storage classes in C are: auto, register, static, and extern. 'static' is one of them.

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

Take Test
In the declaration 'volatile int x;', what does volatile signify?
A x can be changed by external factors unexpectedly
B x cannot be modified after initialization
C x is stored in CPU register for faster access
D x is a temporary variable
Correct Answer:  A. x can be changed by external factors unexpectedly
EXPLANATION

volatile tells the compiler that the variable's value may change unexpectedly (e.g., by hardware, signals, or another thread), so the compiler should not optimize it.

Take Test
What happens when you assign a larger data type value to a smaller one?
A Compilation error occurs
B Implicit type conversion (with possible data loss)
C Runtime error occurs
D The value is automatically promoted
Correct Answer:  B. Implicit type conversion (with possible data loss)
EXPLANATION

C allows implicit type conversion. When assigning larger to smaller type, truncation or data loss may occur without any compiler error.

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

Take Test
Which of the following correctly declares a constant integer variable?
A const int x = 10;
B int const x = 10;
C Both A and B are correct
D constant int x = 10;
Correct Answer:  C. Both A and B are correct
EXPLANATION

Both 'const int' and 'int const' are valid and equivalent ways to declare a constant integer in C.

Take Test
What will be the output of: printf("%d", 5/2)?
A 2.5
B 2
C 3
D Compiler error
Correct Answer:  B. 2
EXPLANATION

Integer division in C truncates the decimal part. 5/2 = 2 (not 2.5). The %d format specifier expects an integer.

Take Test
In the declaration 'int arr[10], *ptr;', which statement is correct?
A ptr is an array pointer, arr is an integer pointer
B ptr is a pointer to int, arr is an array of 10 integers
C Both arr and ptr are integer pointers
D arr is a pointer, ptr is an array
Correct Answer:  B. ptr is a pointer to int, arr is an array of 10 integers
EXPLANATION

The declaration uses comma separation. 'int arr[10]' declares an array of 10 integers, while '*ptr' declares a pointer to int.

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