Learn C MCQs
Prepare C MCQs (Multiple choice Questions) for exam and job interviews.
Which of the following statements is true about the goto statement?
1) It is used to exit from loops.
2) It jumps to a specified label in the code.
3) It skips the current iteration of a loop.
4) None of the above
Answer : It jumps to a specified label in the code.
Which function is used to append data to a file in C?
1) write()
2) fwrite()
3) fput()
4) fputs()
Answer : fwrite()
How do you terminate a string in C?
1) With a semicolon
2) With a period
3) With a null character
4) With a space
Answer : With a null character
Which of the following operators is used to allocate memory in C?
1) new
2) malloc
3) alloc
4) None of the above
Answer : malloc
Which header file should be included to use the printf function?
1) conio.h
2) math.h
3) stdio.h
4) stdlib.h
Answer : stdio.h
Which keyword is used to declare a variable that retains its value between function calls?
1) static
2) extern
3) register
4) auto
Answer : static
What will be the output of printf("%d", 6 & 3);?
1) 6
2) 3
3) 0
4) 2
Answer : 2
Which keyword is used to define a new data type in C?
1) typedef
2) type
3) newtype
4) None of the above
Answer : typedef
Which of the following is the correct syntax for a ternary operator?
1) condition ? expression1 : expression2
2) condition ? expression : expression;
3) if condition then expression
4) condition if expression else expression;
Answer : condition ? expression1 : expression2
What is the correct syntax to pass a function as a parameter in C?
1) func(parameter());
2) function(func());
3) (*func)()
4) None of the above
Answer : (*func)()