Learn C MCQs

Prepare C MCQs (Multiple choice Questions) for exam and job interviews.

What is the size of an integer on a 64-bit system?

1) 2 bytes

2) 4 bytes

3) 8 bytes

4) Depends on the compiler

Answer : 4 bytes

Which of the following correctly declares a pointer?

1) int *ptr;

2) int ptr*;

3) ptr int*;

4) int *ptr();

Answer : int *ptr;

What is the output of printf("%d", 4 ^ 5);?

1) 1

2) 9

3) 8

4) 3

Answer : 1

Which of the following is used to allocate memory dynamically in C?

1) malloc()

2) calloc()

3) realloc()

4) All of the above

Answer : All of the above

What will be the output of printf("%d", 10 && 0);?

1) 0

2) 1

3) 10

4) Error

Answer : Option 1

Which of the following can be used to read a string in C?

1) gets()

2) scanf()

3) fgets()

4) All of the above

Answer : All of the above

What will be the output of printf("%d", 4 * (2 + 3));?

1) 20

2) 15

3) 10

4) 12

Answer : 20

Which of the following is a valid statement to declare an array of 10 integers?

1) int arr[10];

2) int arr();

3) arr int[10];

4) int arr = new int[10];

Answer : int arr[10];

What will be the output of printf("%d", 10 / 2 * 3);?

1) 15

2) 5

3) 10

4) 20

Answer : 15

Which of the following is not a valid arithmetic operator in C?

1) +

2) -

3) /

4) %

Answer : None of the above