C Programming — Data Types & Variables
C language from basics to advanced placement prep
53 Questions 10 Topics Take Test
Advertisement
Showing 1–10 of 53 questions in Data Types & Variables
Consider a scenario where you need to store a variable that can hold values up to 10 billion. Which data type is most suitable?
A int
B long int
C long long int
D float
Correct Answer:  C. long long int
EXPLANATION

int max is ~2.1 billion, long int varies (may be 32 or 64 bits). long long int guarantees 64 bits with max ~9.2 quintillion, sufficient for 10 billion.

Take Test
What is the output of:
int arr[3] = {1, 2, 3};
int *p = arr;
printf("%d %d", *p, *(p+2));
A 1 3
B 1 2
C 3 3
D Garbage values
Correct Answer:  A. 1 3
EXPLANATION

p points to arr[0] which is 1. p+2 points to arr[2] which is 3. Therefore output is '1 3'.

Take Test
Which storage class has both 'static' and 'auto' properties in certain contexts?
A register
B extern
C static
D volatile
Correct Answer:  A. register
EXPLANATION

register requests compiler to store variable in CPU register for faster access but falls back to memory if unavailable, combining automatic allocation with optimization hints.

Take Test
In C, what is the difference between 'int' and 'unsigned int' in terms of range on a 32-bit system?
A unsigned int has double the maximum value
B int ranges from -2^31 to 2^31-1, unsigned int from 0 to 2^32-1
C They have identical ranges
D unsigned int ranges from -2^32 to 2^32
Correct Answer:  B. int ranges from -2^31 to 2^31-1, unsigned int from 0 to 2^32-1
EXPLANATION

signed int reserves 1 bit for sign, giving range -2147483648 to 2147483647. unsigned int uses all 32 bits for magnitude, giving 0 to 4294967295.

Take Test
What is the output of the following code:
int a = 5;
int *p = &a;
int **q = &p;
printf("%d", **q);
A 5
B Address of a
C Address of p
D Compilation error
Correct Answer:  A. 5
EXPLANATION

q is a pointer to pointer p. *q dereferences q to get p, and **q dereferences p to get the value of a, which is 5.

Take Test
Advertisement
Which of the following is a valid declaration of a constant array?
A const int arr[5] = {1,2,3,4,5};
B int const arr[5];
C const int arr[];
D Both A and B
Correct Answer:  D. Both A and B
EXPLANATION

Both declarations make the array elements constant. Option A initializes the array, while B declares it without initialization (valid at global scope).

Take Test
What is the range of values for a signed short int?
A -128 to 127
B -32768 to 32767
C -2147483648 to 2147483647
D 0 to 65535
Correct Answer:  B. -32768 to 32767
EXPLANATION

Signed short int is typically 2 bytes (16 bits), providing a range from -2^15 to 2^15-1.

Take Test
Which of these correctly represents a floating-point literal with exponent notation?
A 1.5e2
B 1.5e
C 1e2.5
D e1.5
Correct Answer:  A. 1.5e2
EXPLANATION

Correct exponent notation requires a digit before and after 'e'. 1.5e2 represents 1.5 × 10² = 150.0

Take Test
What will be the output: const int x = 10; x = 20; printf("%d", x);
A 10
B 20
C Compilation error
D Runtime error
Correct Answer:  C. Compilation error
EXPLANATION

const variables cannot be modified after initialization. Attempting to assign a new value causes a compilation error.

Take Test
Which storage class specifier limits a variable's scope to the current file?
A extern
B static
C register
D auto
Correct Answer:  B. static
EXPLANATION

The 'static' keyword, when used at file scope, restricts the variable's visibility to that file only (internal linkage).

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