c programming banner

C Programming Multiple Choice Questions (MCQs) and Answers

Master C Programming with Practice MCQs. Explore our curated collection of Multiple Choice Questions. Ideal for placement and interview preparation, our questions range from basic to advanced, ensuring comprehensive coverage of C Programming. Begin your placement preparation journey now!

Q31

Q31 What is the output of the following C code snippet?
int main() {
int x
= 10;
printf("%d", x++ + ++x);
return 0;
}

A

20

B

21

C

22

D

23

Q32

Q32 What is the result of the following expression?
int a = 1; int b = a++ + ++a;

A

2

B

3

C

4

D

5

Q33

Q33 Pseudocode:

SET x TO 5, y TO 10 IF x LESS THAN y THEN PRINT "x is less than y" ELSE PRINT "x is not less than y"

A

Prints "x is less than y"

B

Prints "x is not less than y"

C

Prints nothing

D

Syntax error

Q34

Q34 Pseudocode:

SET a TO 10, b TO 20 PRINT a PLUS b

A

30

B

20

C

10

D

0

Q35

Q35 Pseudocode:

SET num TO 5 IF num EQUALS 5 THEN PRINT "Five" ELSE PRINT "Not Five"

A

Prints "Five"

B

Prints "Not Five"

C

Prints nothing

D

Syntax error

Q36

Q36 Pseudocode:

SET value TO 10 PRINT NOT value

A

-10

B

0

C

1

D

10

Q37

Q37 Pseudocode:

SET a TO 10, b TO 20 IF a GREATER THAN b THEN PRINT "a is greater" ELSE PRINT "b is greater or equal"

A

Prints "a is greater"

B

Prints "b is greater or equal"

C

Prints nothing

D

Syntax error

Q38

Q38 Pseudocode:

SET x TO 5 IF x GREATER THAN 0 AND x LESS THAN 10 THEN PRINT "x is between 0 and 10"

A

Prints "x is between 0 and 10"

B

Prints nothing

C

Syntax error

D

Prints "x is not between 0 and 10"

Q39

Q39 Pseudocode:

SET c TO 15 IF c MOD 2 EQUALS 0 THEN PRINT "Even" ELSE PRINT "Odd"

A

Prints "Even"

B

Prints "Odd"

C

Prints nothing

D

Syntax error

Q40

Q40 Spot the error:
int main() {
int a = 10, b = 0;
printf("%d", a / b);
return 0;
}

A

Division by zero

B

Syntax error

C

No error

D

Wrong format specifier

Q41

Q41 Identify the mistake:
int main() {
int x = 10, y; y = x == 10 ? x : 0;
printf("%d", y);
return 0;
}

A

Incorrect use of ternary operator

B

Syntax error

C

No error

D

Wrong variable used

Q42

Q42 What does the break statement do in a loop?

A

Exits the loop

B

Skips the current iteration

C

Repeats the loop

D

Does nothing

Q43

Q43 What is the difference between for and while loops?

A

Syntax

B

Execution speed

C

Functionality

D

No difference

Q44

Q44 In a switch statement, what happens if a break statement is omitted from a case?

A

The program exits

B

The case is skipped

C

Fall-through to the next case

D

Syntax error

Q45

Q45 What is the purpose of the continue statement in loops?

A

Terminates the loop

B

Skips to the next iteration

C

Does nothing

D

Exits the program

Q46

Q46 When is a do-while loop preferred over a while loop?

A

When the condition is complex

B

When the loop must execute at least once

C

When the loop should not execute

D

When the loop is infinite

Q47

Q47 What will the following C code print?
int main() {
for(int i = 0; i < 3; i++)
{ printf("%d ", i); }
return 0;
}

A

0 1 2

B

1 2 3

C

0 1 2 3

D

1 2 3 4

Q48

Q48 What does this C code do?
int main()
{ int i = 0;
while(i < 5) { if(i == 2) break;
printf("%d ", i); i++; }
return 0;
}

A

Prints 0 1 2

B

Prints 0 1

C

Prints all numbers less than 5

D

Prints nothing

Q49

Q49 What is the output of the following C code?
int main() {
int x = 0; do {
printf("%d ", x);
x++;
} while(x < 3);
return 0;
}

A

0 1 2

B

0 1

C

1 2 3

D

No output

Q50

Q50 Pseudocode:

SET num TO 10 IF num EQUALS 10 THEN PRINT "Ten" ELSE PRINT "Not Ten"

A

Prints "Ten"

B

Prints "Not Ten"

C

Prints nothing

D

Syntax error

Q51

Q51 Pseudocode:

SET x TO 5 WHILE x GREATER THAN 0 DO PRINT x DECREMENT x

A

Prints numbers from 5 to 1 in descending order

B

Prints 5

C

Prints 0

D

Syntax error

Q52

Q52 Pseudocode:

FOR i FROM 1 TO 5 PRINT i

A

Prints numbers from 1 to 5

B

Prints numbers from 1 to 4

C

Prints 5

D

Syntax error

Q53

Q53 Pseudocode:

SET count TO 0 REPEAT PRINT count INCREMENT count UNTIL count EQUALS 3

A

Prints 0 1 2 3

B

Prints 0 1 2

C

Prints 3

D

Syntax error

Q54

Q54 Pseudocode:

SET i TO 0 WHILE i LESS THAN 10 IF i MOD 2 EQUALS 0 THEN CONTINUE INCREMENT i PRINT i END WHILE

A

Prints odd numbers from 1 to 9

B

Prints even numbers from 0 to 8

C

Prints all numbers from 0 to 9

D

Syntax error

Q55

Q55 Identify the error in this C code:
int main() {
int i = 0;
while(i < 3) {
i++;
}
printf("%d ", i);
return 0;
}

A

Infinite loop

B

Syntax error

C

No error

D

Prints nothing

Q56

Q56 Spot the mistake:
int main() {
for(int i = 0; i < 5; i++) {
if(i == 2)
continue;
printf("%d ", i);
} return 0;
}

A

Infinite loop

B

Skips printing 2

C

Syntax error

D

No error

Q57

Q57 What is the primary purpose of a function in C?

A

Code reuse and modularity

B

Error handling

C

Memory management

D

User interface creation

Q58

Q58 What does 'pass by value' mean in C?

A

Passing a copy of the argument

B

Passing the argument directly

C

Passing the memory address

D

Passing the variable type

Q59

Q59 What is recursion in C?

A

A function calling another function

B

A function that has no return type

C

A function calling itself

D

A loop within a function

Q60

Q60 What is the scope of a local variable in C?

A

Inside the function in which it is declared

B

Throughout the program

C

Inside the file

D

Throughout the function block where it is declared

ad verticalad vertical
ad