an HCL GUVI product

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!

Q1

Q1 Why is learning programming important in today's world?

A

For academic purposes only

B

To automate and solve complex problems

C

Only for software development

D

For entertainment purposes only

Q2

Q2 Which of the following is true about interpreters?

A

They execute programs faster than compilers

B

They translate the entire program at once

C

They translate and execute code line by line

D

They are not used in modern programming

Q3

Q3 What is the primary purpose of writing a "Hello World" program when learning a new programming language?

A

To test if the language supports string operations

B

To learn complex programming concepts

C

To demonstrate basic syntax and output

D

To introduce advanced programming features

Q4

Q4 Identify the error in this C program:
#include <stdio.h>
int main() {
print("Hello, World!");
return 0;
}

A

Missing #include statement

B

Incorrect function name

C

Syntax error in return statement

D

No error

Q5

Q5 What data type would you use to store a character in C?

A

int

B

float

C

char

D

double

Q6

Q6 What is the size of 'int' data type in C?

A

Depends on the system

B

4 bytes

C

8 bytes

D

2 bytes

Q7

Q7 What will be the output of the following C code?
int main() {
char c = 'A';
printf("%d", c);
return 0;
}

A

65

B

A

C

Syntax Error

D

None of these

Q8

Q8 Spot the error in this code snippet:
#include <stdio.h>
int main() {
const int age; age = 30;
printf("%d", age);
return 0;
}

A

Uninitialized constant

B

Missing return statement

C

Syntax error in printf statement

D

No error

Q9

Q9 What is the purpose of the printf function in C?

A

To read input

B

To print output

C

To perform calculations

D

To control program flow

Q10

Q10 What will the following C code output?
int main() {
int num;
scanf("%d", &num);
printf("%d", num);
return 0;
}

A

The inputted number

B

%d

C

Syntax Error

D

Nothing

Q11

Q11 Identify the error in this C code:
int main() {
int x;
scanf("%d", x);
printf("%d", x);
return 0;
}

A

Missing & in scanf

B

Wrong format specifier

C

No error

D

Syntax error

Q12

Q12 Which operator is used for division in C?

A

-

B

*

C

/

D

=+

Q13

Q13 What does the '!' operator do in C?

A

Negation

B

Addition

C

Multiplication

D

None

Q14

Q14 What will be the output of the following C code?
int main() {
int a = 10, b = 5;
printf("%d", a / b);
return 0;
}

A

2

B

5

C

0

D

10

Q15

Q15 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

Q16

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

A

2

B

3

C

4

D

5

Q17

Q17 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

Q18

Q18 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

Q19

Q19 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

Q20

Q20 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

Q21

Q21 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

Q22

Q22 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

Q23

Q23 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

Q24

Q24 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

Q25

Q25 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

Q26

Q26 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

Q27

Q27 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

Q28

Q28 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

Q29

Q29 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

Q30

Q30 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

ad vertical