Learn C MCQs
Prepare C MCQs (Multiple choice Questions) for exam and job interviews.
Which of the following is a valid comment in C?
1) // This is a comment
2) /* This is a comment */
3) # This is a comment
4) Both 1 and 2
Answer : Both 1 and 2
Which of the following is not a standard library in C?
1) stdlib.h
2) stdio.h
3) conio.h
4) data.h
Answer : data.h
What does the keyword `extern` indicate in C?
1) Variable is defined in another file.
2) Variable is local to the function.
3) Variable is a constant.
4) None of the above
Answer : Variable is defined in another file.
What is the value of `x` after the following statement: x = 5 + 3 * 2;
1) 8
2) 11
3) 10
4) None of the above
Answer : 11
What will be the output of printf("%d", 7 - 2 * 3);?
1) 1
2) 7
3) 3
4) 2
Answer : 1
Which operator is used to perform bitwise OR in C?
1) ||
2) |
3) &
4) ^
Answer : |
Which of the following functions is used to sort an array in C?
1) sort()
2) qsort()
3) arrsort()
4) None of the above
Answer : qsort()
Which function is used to allocate memory dynamically in C?
1) alloc()
2) malloc()
3) calloc()
4) new()
Answer : malloc()
What is the output of printf("%d", sizeof(int));?
1) 2
2) 4
3) 8
4) Depends on the system
Answer : Depends on the system
Which of the following statements is used to define a macro in C?
1) #define
2) #macro
3) define
4) None of the above
Answer : #define