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 : Option 2

Which function is used to append data to a file in C?

1) write()

2) fwrite()

3) fput()

4) fputs()

Answer : Option 2

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 : Option 3

Which of the following operators is used to allocate memory in C?

1) new

2) malloc

3) alloc

4) None of the above

Answer : Option 2

Which header file should be included to use the printf function?

1) conio.h

2) math.h

3) stdio.h

4) stdlib.h

Answer : Option 3

Which keyword is used to declare a variable that retains its value between function calls?

1) static

2) extern

3) register

4) auto

Answer : Option 1

What will be the output of printf("%d", 6 & 3);?

1) 6

2) 3

3) 0

4) 2

Answer : Option 4

Which keyword is used to define a new data type in C?

1) typedef

2) type

3) newtype

4) None of the above

Answer : Option 1

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 : Option 1

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 : Option 3