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 : All of the above

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 : int (*func)();

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

1) 14

2) 13

3) 9

4) Error

Answer : 14

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 : return value;

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 : The variable can change unexpectedly.

Which function is used to copy a string in C?

1) strcopy()

2) strcpy()

3) copy()

4) strdup()

Answer : strcpy()

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 : struct name = {value1, value2};

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 : int arr[2][3];

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

1) strchr()

2) strstr()

3) strfind()

4) strindex()

Answer : strchr()

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

1) 3

2) 7

3) 5

4) 1

Answer : 7