Learn C MCQs
Prepare C MCQs (Multiple choice Questions) for exam and job interviews.
Which of the following functions can be used to find the absolute value of a number?
1) abs()
2) fabs()
3) Both 1 and 2
4) None of the above
Answer : Both 1 and 2
What is the output of printf("%d", 8 >> 2);?
1) 2
2) 4
3) 1
4) 3
Answer : 2
Which of the following is a valid way to declare a string?
1) char str[];
2) char str[10];
3) Both 1 and 2
4) char str;
Answer : Both 1 and 2
What is the output of printf("%d", (5 + 3) * 2);?
1) 16
2) 14
3) 10
4) 12
Answer : 16
What does the `continue` statement do in a loop?
1) Skips the current iteration
2) Ends the loop
3) Starts the loop over
4) None of the above
Answer : Skips the current iteration
What is the output of printf("%d", 1 + 2 + 3);?
1) 6
2) 5
3) 4
4) 7
Answer : 6
Which of the following is not a valid type in C?
1) int
2) float
3) double
4) string
Answer : string
What is the output of printf("%d", 5 == 5);?
1) 1
2) 0
3) 5
4) 10
Answer : 1
Which of the following is the correct way to declare a multi-dimensional array?
1) int arr[3][4];
2) int arr[4][3];
3) Both 1 and 2
4) None of the above
Answer : Both 1 and 2
What is the output of printf("%d", 5 | 3);?
1) 6
2) 8
3) 5
4) 7
Answer : 7