Learn C MCQs

Prepare C MCQs (Multiple choice Questions) for exam and job interviews.

What is the correct syntax to declare a variable in C?

1) a int;

2) int a;

3) int:a;

4) None of the above

Answer : Option 2

Which of the following is used to comment in C?

1) // comment

2) /* comment */

3) # comment

4) Both a and b

Answer : Option 2

Which operator is used to access the value at the address of a pointer?

1) ->

2) &

3) @

4) *

Answer : Option 4

Which function is used to print output in C?

1) printf()

2) print()

3) cout<<

4) console.log()

Answer : Option 1

What is the return type of the main function in C?

1) int

2) void

3) float

4) None of the above

Answer : Option 1

Which of the following is a valid loop in C?

1) for

2) foreach

3) loop

4) doWhile

Answer : Option 1

How do you declare an array in C?

1) int array();

2) array arr(10);

3) int arr[10];

4) None of the above

Answer : Option 3

Which header file is required for using standard input and output functions in C?

1) stdio.h

2) stdlib.h

3) conio.h

4) math.h

Answer : Option 1

What is the correct way to define a constant in C?

1) PI = 3.14

2) #define PI 3.14

3) const PI = 3.14;

4) None of the above

Answer : Option 2

What is the correct way to define a pointer in C?

1) int ptr;

2) ptr int*;

3) *int ptr;

4) int *ptr;

Answer : Option 4