Learn C MCQs

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

Which of the following can be used to convert a string to an integer in C?

1) atoi()

2) strtoi()

3) int()

4) stringToInt()

Answer : Option 1

What is the output of printf("%d", 6 | 3);?

1) 5

2) 6

3) 7

4) 4

Answer : Option 3

Which of the following is the correct way to define a union in C?

1) union name { int x; };

2) struct name { int x; };

3) union { int x; } name;

4) None of the above

Answer : Option 1

What is the output of printf("%d", 1 << 3);?

1) 3

2) 4

3) 8

4) 2

Answer : Option 3

Which of the following is not a storage class in C?

1) auto

2) static

3) register

4) dynamic

Answer : Option 4

What is the purpose of the `continue` statement?

1) To skip the current iteration

2) To exit the loop

3) To restart the loop

4) None of the above

Answer : Option 1

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

1) 24

2) 18

3) 20

4) 30

Answer : Option 2

What is the output of printf("%d", sizeof(char));?

1) 1

2) 2

3) 4

4) Depends on the compiler

Answer : Option 1

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

1) .

2) ->

3) Both 1 and 2

4) None of the above

Answer : Option 3

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

1) 15

2) 20

3) 25

4) 12

Answer : Option 1