Learn C MCQs

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

Which of the following is a valid way to declare an array of 5 floats?

1) float arr[5];

2) float arr();

3) float arr = {1.0, 2.0};

4) None of the above

Answer : Option 1

What is the purpose of the `break` statement in a loop?

1) To exit the loop

2) To continue to the next iteration

3) To skip the current iteration

4) None of the above

Answer : Option 1

Which of the following will not compile in C?

1) int x = 10;

2) int 1x = 10;

3) float y = 5.5;

4) char c = 'A';

Answer : Option 2

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

1) 2

2) 1

3) 3

4) 0

Answer : Option 2

Which of the following is used for dynamic memory allocation in C?

1) malloc()

2) alloc()

3) new

4) None of the above

Answer : Option 1

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

1) 9

2) 6

3) 4

4) 5

Answer : Option 2

Which of the following statements is used to include a header file?

1) #include

2) #include header

3) import header

4) require header

Answer : Option 1

What is the purpose of the `continue` statement in a loop?

1) To exit the loop

2) To skip to the next iteration

3) To break out of the loop

4) None of the above

Answer : Option 2

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

1) 11

2) 7

3) 15

4) 12

Answer : Option 1

Which of the following is a valid pointer declaration?

1) int *ptr;

2) ptr int*;

3) *ptr int;

4) int * ptr;

Answer : Option 1