Home Subjects C Programming

C Programming

C language from basics to advanced placement prep

303 Q 10 Topics Take Test
Advertisement
Difficulty: All Easy Medium Hard 241–250 of 303
Topics in C Programming
Which of the following variable declarations will occupy the LEAST memory?
A unsigned int x;
B float y;
C char z;
D double w;
Correct Answer:  C. char z;
EXPLANATION

char data type typically occupies 1 byte, which is the minimum. int is 4 bytes, float is 4 bytes, and double is 8 bytes on most systems.

Take Test
Which keyword is used to declare a variable that cannot be modified after initialization?
A static
B volatile
C const
D extern
Correct Answer:  C. const
EXPLANATION

The 'const' keyword declares a constant variable whose value cannot be modified after initialization. Attempting to modify it results in a compile-time error.

Take Test
What is the size of a 'long long int' variable in C on a 64-bit system?
A 4 bytes
B 8 bytes
C 16 bytes
D Compiler dependent
Correct Answer:  B. 8 bytes
EXPLANATION

A 'long long int' is guaranteed to be at least 64 bits (8 bytes) by the C99 standard on all systems including 64-bit architectures.

Take Test
In C programming, which of the following is NOT a fundamental data type?
A int
B float
C string
D double
Correct Answer:  C. string
EXPLANATION

string is not a fundamental data type in C. Fundamental types are int, float, double, char, and void. Strings are arrays of characters.

Take Test
What is the output of: int a = 5, b = 2; printf("%d", a / b);
A 2.5
B 2
C 3
D Compilation error
Correct Answer:  B. 2
EXPLANATION

Both a and b are integers, so integer division is performed: 5/2 = 2 (remainder discarded).

Take Test
Which data type would be most appropriate to store a person's age in a program?
A float
B double
C int
D char
Correct Answer:  C. int
EXPLANATION

Age is an integer value. Using 'int' is appropriate and memory-efficient. Floating-point types are unnecessary for this discrete value.

Take Test
What is the difference between 'signed' and 'unsigned' char?
A Only storage capacity differs
B Range of values they can store differs
C Signed cannot store special characters
D Unsigned uses more memory
Correct Answer:  B. Range of values they can store differs
EXPLANATION

Signed char ranges from -128 to 127, while unsigned char ranges from 0 to 255. Both use 1 byte but interpret the bits differently.

Take Test
What is the size of the 'char' data type in C on most modern systems?
A 1 byte
B 2 bytes
C 4 bytes
D 8 bytes
Correct Answer:  A. 1 byte
EXPLANATION

The 'char' data type occupies 1 byte (8 bits) of memory on virtually all modern C systems, as per the C standard.

Take Test
What happens if you assign a double value to an int variable without casting?
A Compilation error
B The fractional part is truncated
C The value is rounded
D Runtime error
Correct Answer:  B. The fractional part is truncated
EXPLANATION

Implicit conversion truncates decimal part. int x = 3.7; results in x=3 with no error.

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

Signed char uses 8 bits with one bit for sign, giving range -128 to 127 (2^7 to 2^7-1).

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