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 : atoi()
What is the output of printf("%d", 6 | 3);?
1) 5
2) 6
3) 7
4) 4
Answer : 7
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 : union name { int x; };
What is the output of printf("%d", 1 << 3);?
1) 3
2) 4
3) 8
4) 2
Answer : 8
Which of the following is not a storage class in C?
1) auto
2) static
3) register
4) dynamic
Answer : dynamic
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 : To skip the current iteration
What will be the output of printf("%d", 3 * (4 + 2));?
1) 24
2) 18
3) 20
4) 30
Answer : 18
What is the output of printf("%d", sizeof(char));?
1) 1
2) 2
3) 4
4) Depends on the compiler
Answer : 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 : Both 1 and 2
What is the output of printf("%d", 10 / 2 * 3);?
1) 15
2) 20
3) 25
4) 12
Answer : 15