Learn C MCQs

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

Which of the following operators is used to access members of a structure?

1) .

2) ->

3) ::

4) Both 1 and 2

Answer : Both 1 and 2

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

1) 10

2) 15

3) 30

4) 20

Answer : 15

Which of the following is not a valid variable type in C?

1) float

2) double

3) decimal

4) int

Answer : decimal

What is the purpose of the `goto` statement in C?

1) To jump to a label

2) To create loops

3) To define functions

4) None of the above

Answer : To jump to a label

Which of the following is used to free allocated memory?

1) delete

2) free()

3) dispose()

4) remove()

Answer : free()

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

1) 30

2) 25

3) 50

4) 35

Answer : 30

Which of the following statements is true about pointers?

1) They store the address of a variable.

2) They can be dereferenced.

3) They can be incremented.

4) All of the above

Answer : All of the above

What is the output of printf("%d", 5 | 1);?

1) 5

2) 4

3) 1

4) 7

Answer : 5

What is the output of printf("%d", 10 && 2);?

1) 1

2) 0

3) 10

4) 2

Answer : 1

Which of the following is a correct way to declare a 2D array in C?

1) int arr[3][4];

2) int arr(3)(4);

3) int arr{3}{4};

4) int arr[3,4];

Answer : int arr[3][4];