Learn C MCQs

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

Which of the following is a preprocessor directive in C?

1) #define

2) #include

3) #ifdef

4) All of the above

Answer : Option 4

Which of the following is a correct declaration of a function pointer?

1) int (*func)();

2) int func*();

3) func* int();

4) None of the above

Answer : Option 1

What will be the output of the following code: printf("%d", 4 + 5 * 2);?

1) 14

2) 13

3) 9

4) Error

Answer : Option 1

Which of the following statements is used to return a value from a function in C?

1) return; value;

2) return value;

3) return(value);

4) None of the above

Answer : Option 2

What does the keyword `volatile` indicate in C?

1) The variable can change unexpectedly.

2) The variable will not change.

3) The variable is not initialized.

4) None of the above

Answer : Option 1

Which function is used to copy a string in C?

1) strcopy()

2) strcpy()

3) copy()

4) strdup()

Answer : Option 2

What is the correct way to initialize a structure in C?

1) struct name = {value1, value2};

2) struct name {value1, value2};

3) struct name = (value1, value2);

4) None of the above

Answer : Option 1

Which of the following correctly represents a multi-dimensional array?

1) int arr[2][3];

2) int arr(2,3);

3) int arr[2,3];

4) None of the above

Answer : Option 1

Which function returns a pointer to the first occurrence of a character in a string?

1) strchr()

2) strstr()

3) strfind()

4) strindex()

Answer : Option 1

What will be the output of printf("%d", 5 | 2);?

1) 3

2) 7

3) 5

4) 1

Answer : Option 2