C Data Types MCQ

Data types are integral to C programming. They help in classifying the type of data, ensuring proper memory allocation, and enabling appropriate operations on the data. This quiz is designed for beginners to test their understanding of the fundamental data types in C. Let’s jump right in!

Note that each question is followed by the correct answer and an explanation to help reinforce your knowledge.

1. Which of the following is a derived data type in C?

A) int
B) float
C) array
D) char

Answer:

C) array

Explanation:

Arrays are derived data types in C, created using fundamental types like int, char, etc.

2. What is the size (in bytes) of double on most modern systems?

A) 4
B) 6
C) 8
D) 10

Answer:

C) 8

Explanation:

On most systems, a double is 8 bytes. But it’s always good to check using the sizeof() operator for platform-specific sizes.

3. What data type is best suited for storing a single character?

A) int
B) bool
C) char
D) double

Answer:

C) char

Explanation:

The char data type is specifically designed for storing a single character.

4. Which of the following is a non-standard integer type?

A) int
B) long int
C) byte
D) short int

Answer:

C) byte

Explanation:

byte is not a standard integer type in C.

5. How many bytes does the int data type usually occupy?

a) 1
b) 2
c) 4
d) 8

Answer:

c) 4

Explanation:

Typically, in most modern systems, an int occupies 4 bytes (32 bits), but this can vary depending on the system and compiler.

6. Which of the following types can store a larger range of integers?

A) short
B) int
C) long long
D) long

Answer:

C) long long

Explanation:

long long can typically store larger integers compared to the other listed types.

7. Which data type in C has only two possible values?

A) char
B) bool
C) int
D) double

Answer:

B) bool

Explanation:

The _Bool (or bool with stdbool.h included) can have only two values: true or false.

8. Which of the following is not a floating-point data type?

A) float
B) double
C) long double
D) long int

Answer:

D) long int

Explanation:

long int is an integer type, not a floating-point type.

9. Which type is used to store a wide character in C?

A) char
B) w_char
C) wchar_t
D) wide

Answer:

C) wchar_t

Explanation:

wchar_t is used for wide characters.

10. If a variable is declared as unsigned short int, what is its typical size on modern systems?

A) 1 byte
B) 2 bytes
C) 4 bytes
D) 8 bytes

Answer:

B) 2 bytes

Explanation:

Typically, an unsigned short int occupies 2 bytes on modern systems.

11. Which of the following data types has the smallest storage size?

A) float
B) double
C) long double
D) char

Answer:

D) char

Explanation:

Typically, a char occupies 1 byte, making it smaller than the other listed data types.

12. What would be the outcome of sizeof(_Bool) in C?

A) 0
B) 1
C) 2
D) 4

Answer:

B) 1

Explanation:

The _Bool type, or bool when including stdbool.h, typically occupies 1 byte.

13. What is the primary difference between int and unsigned int?

A) Memory allocation
B) Range of values
C) Data type classification
D) Operation types

Answer:

B) Range of values

Explanation:

Both int and unsigned int typically occupy the same memory, but unsigned int can’t store negative values, extending its positive range.

14. Which data type would be most suitable for storing the value of PI (3.14159…)?

a) int
b) float
c) double
d) char

Answer:

c) double

Explanation:

double provides more precision than float, making it more suitable for storing the value of PI.

15. Which data type is used to store a sequence of characters?

a) sequence
b) char sequence[]
c) string
d) char[]

Answer:

d) char[]

Explanation:

In C, a sequence of characters (a string) is stored as an array of char, i.e., char[].


Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top