C MCQ Questions

Our website offers a large collection of C programming MCQs to help learners practice and improve their coding skills. Covering essential topics like data types, pointers, arrays, functions, structures, and file handling, each question tests important concepts with clear explanations. It is perfect for students, beginners, and professionals preparing for exams or job interviews. This platform makes learning C programming easier, practical, and effective for academic and career success.

Q1. Which of the following is the correct syntax to declare a pointer in C?

Correct Answer: B

In C, a pointer is declared with an asterisk symbol, e.g., int *ptr;

Q2. Which of the following is the default return type of a C function if not specified?

Correct Answer: A

In C, if no return type is given, the default is int.

Q3. Which format specifier is used to print an integer in C?

Correct Answer: C

%d is used to print integer values in C.

Q4. Which of the following is a valid storage class in C?

Correct Answer: B

C supports storage classes: auto, static, register, extern.

Q5. What will be the output of sizeof(char) in C?

Correct Answer: A

By standard, sizeof(char) is always 1 byte.

Q6. Which operator is used to access the value stored at an address in C?

Correct Answer: B

The * operator is the dereference operator to access value at a pointer.

Q7. What is the correct way to declare a constant in C?

Correct Answer: D

const int a = 10; declares a constant integer in C.

Q8. Which header file is required for using printf and scanf functions?

Correct Answer: B

printf and scanf are declared in stdio.h.

Q9. Which keyword is used to break out of a loop in C?

Correct Answer: D

break keyword immediately terminates a loop.

Q10. What is the output of 5/2 in C?

Correct Answer: B

In C, when both operands of the division operator / are integers, integer division is performed. Therefore, 5 / 2 does not produce 2.5; the fractional part is discarded, and the result is 2. If you wanted the result to be 2.5, at least one operand would need to be a floating-point value, such as 5.0 / 2 or 5 / 2.0. Hence, the correct answer is B. 2.

Q11. Which function is used to allocate memory dynamically in C?

Correct Answer: A

malloc() is used to allocate memory dynamically.

Q12. Which operator is used for conditional evaluation in C?

Correct Answer: C

The ternary operator ?: provides conditional evaluation.

Q13. Which of the following functions is used to compare two strings in C?

Correct Answer: B

strcmp() compares two strings character by character.

Q14. What is the index of the first element in a C array?

Correct Answer: A

C arrays are zero-indexed, so the first element has index 0.

Q15. Which of the following is not a loop structure in C?

Correct Answer: C

C has for, while, and do-while loops; foreach is not in C.

Q16. Which keyword is used to define a macro in C?

Correct Answer: C

#define is used to create macros in C.

Q17. Which function is used to find the length of a string in C?

Correct Answer: B

strlen() returns the number of characters in a string.

Q18. Which of the following data types has the largest size in C?

Correct Answer: D

long double generally has the largest size among standard C types.

Q19. Which loop will execute at least once in C?

Correct Answer: C

do-while loop executes the body first and checks the condition later.

Q20. What is the correct file extension for a C source file?

Correct Answer: C

C programs are saved with .c extension.

Latest Blogs