“Top 120 C Programming MCQs with Answers 2026”

 “Top 120 C Programming MCQs with Answers 2026”



Prepare smarter with MCQ Journey’s
Top 120 C Programming MCQs with Answers 2026, designed for students, professionals, and competitive exam aspirants. This comprehensive collection of multiple-choice questions covers essential topics in C programming, including data types, control structures, functions, arrays, pointers, and file handling. Each MCQ is carefully curated with detailed answers to help learners strengthen concepts, practice effectively, and boost confidence for exams like GATE, UGC NET, SSC, campus placements, and technical interviews. Whether you are revising for university tests or preparing for competitive exams, these practice questions provide a reliable resource for exam preparation and self-assessment. With keyword-focused content such as “C Programming MCQs with answers,” “exam preparation,” “competitive exams,” and “practice questions,” this post is optimized to rank higher on Google while delivering real value to learners. MCQ Journey ensures a student-friendly, authoritative approach to learning, making it the perfect destination for mastering C programming through MCQs.

Q1. Which of the following is a valid C variable name?

A. int B. float C. total_marks D. continue Answer: C

Q2. Which operator is used to access the value at the address stored in a pointer?

A. & B. * C. -> D. % Answer: B

Q3. What is the default return type of a function in C if not specified?

A. int B. void C. float D. char Answer: A

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

A. auto B. register C. static D. volatile Answer: D

Q5. What will be the output of printf("%d", sizeof(char));?

A. 0 B. 1 C. 2 D. 4 Answer: B

Q6. Which of the following functions is used to read a string from the user in C?

A. scanf() B. gets() C. fgets() D. read() Answer: B Explanation: gets() reads a string until newline, but it is unsafe. fgets() is safer.

Q7. What is the output of printf("%d", 5/2);?

A. 2.5 B. 2 C. 3 D. Error Answer: B Explanation: Integer division truncates the decimal part.

Q8. Which keyword is used to define a constant in C?

A. const B. static C. define D. final Answer: A

Q9. Which of the following is used to dynamically allocate memory in C?

A. malloc() B. calloc() C. realloc() D. All of the above Answer: D

Q10. What is the size of an int on most modern compilers?

A. 2 bytes B. 4 bytes C. 8 bytes D. Depends on compiler Answer: D

Q11. Which of the following is a valid declaration of a pointer in C?

A. int p; B. int *p; C. pointer int p; D. int &p; Answer: B

Q12. What is the output of printf("%c", 'A' + 1);?

A. A B. B C. C D. Error Answer: B Explanation: ASCII value of 'A' is 65, adding 1 gives 66 which corresponds to 'B'.

Q13. Which function is used to compare two strings in C?

A. strcmp() B. strcopy() C. strcat() D. strcomp() Answer: A

Q14. Which of the following is true about arrays in C?

A. Array index starts at 1 B. Array index starts at 0 C. Array index starts at -1 D. Array index can start anywhere Answer: B

Q15. What is the output of printf("%d", sizeof(3.14));?

A. 2 B. 4 C. 8 D. Depends on compiler Answer: C

Q16. Which of the following is the correct way to declare a structure in C?

A. struct student { int id; char name[20]; }; B. structure student { int id; char name[20]; }; C. student struct { int id; char name[20]; }; D. declare struct student { int id; char name[20]; }; Answer: A

Q17. Which operator is used for bitwise AND in C?

A. && B. & C. | D. ^ Answer: B

Q18. What is the output of printf("%d", 10 % 3);?

A. 1 B. 2 C. 3 D. 0 Answer: B Explanation: 10 divided by 3 leaves a remainder of 1, but % gives remainder → 10 % 3 = 1.

Q19. Which function is used to open a file in C?

A. fopen() B. openfile() C. fileopen() D. fcreate() Answer: A

Q20. Which keyword is used to exit from a loop in C?

A. stop B. exit C. break D. continue Answer: C

Q21. Which of the following is the correct syntax to declare a function in C?

A. function int sum(int a, int b); B. int sum(int a, int b); C. declare sum(int a, int b); D. sum(int a, int b) int; Answer: B

Q22. Which loop is guaranteed to execute at least once in C?

A. for loop B. while loop C. do…while loop D. nested loop Answer: C Explanation: The do…while loop executes the body first before checking the condition.

Q23. Which of the following is used to define macros in C?

A. #macro B. #define C. #include D. #typedef Answer: B

Q24. Which operator is used to access members of a structure through a pointer?

A. . B. -> C. * D. & Answer: B

Q25. What is the output of printf("%d", 2 << 1);?

A. 2 B. 4 C. 8 D. 1 Answer: B

Q26. Which of the following is the correct way to declare an array in C?

A. int arr[10]; B. array int arr(10); C. int arr = [10]; D. declare arr[10] int; Answer: A

Q27. What is the output of printf("%d", 7 & 3);?

A. 1 B. 2 C. 3 D. 7 Answer: C Explanation: Bitwise AND of 7 (111) and 3 (011) is 3 (011).

Q28. Which of the following functions is used to write formatted output to a file in C?

A. fprintf() B. fwrite() C. fputs() D. fprint() Answer: A

Q29. Which keyword is used to define an enumeration in C?

A. enum B. enumerate C. typedef D. struct Answer: A

Q30. What is the output of printf("%d", sizeof(0.5f));?

A. 2 B. 4 C. 8 D. Depends on compiler Answer: B

Q31. Which of the following is the correct way to declare a pointer to a function in C?

A. int f(); B. int (f)(); C. function int f(); D. int f(); Answer: B

Q32. What is the output of printf("%d", 5 >> 1);?

A. 2 B. 3 C. 5 D. 10 Answer: A Explanation: Right shift operator divides by 2; 5 (binary 101) shifted once becomes 2 (binary 10).

Q33. Which function is used to allocate memory and initialize it to zero in C?

A. malloc() B. calloc() C. realloc() D. free() Answer: B

Q34. Which of the following is true about recursion in C?

A. A function can call itself. B. Recursion is not allowed in C. C. Only main() can be recursive. D. Recursion requires pointers. Answer: A

Q35. Which function is used to close a file in C?

A. fclose() B. closefile() C. endfile() D. terminate() Answer: A

Q36. Which of the following is the correct format specifier for printing a float in C?

A. %d B. %f C. %c D. %lf Answer: B

Q37. What is the output of printf("%d", 3 == 3);?

A. 0 B. 1 C. True D. False Answer: B Explanation: In C, relational expressions return 1 for true and 0 for false.

Q38. Which of the following functions is used to copy one string into another in C?

A. strcpy() B. strncpy() C. strcopy() D. copystr() Answer: A

Q39. Which keyword is used to define a constant symbolic name in C?

A. const B. #define C. static D. final Answer: B

Q40. Which of the following is the correct way to declare a union in C?

A. union data { int x; float y; }; B. data union { int x; float y; }; C. declare union data { int x; float y; }; D. union { int x; float y; } data; Answer: A

Q41. Which of the following is the correct format specifier for printing a character in C?

A. %d B. %c C. %s D. %f Answer: B

Q42. What is the output of printf("%d", 4 == 5);?

A. 0 B. 1 C. True D. False Answer: A Explanation: 4 is not equal to 5, so the relational expression returns 0 (false).

Q43. Which function is used to concatenate two strings in C?

A. strcat() B. strjoin() C. stradd() D. strmerge() Answer: A

Q44. Which keyword is used to define a type alias in C?

A. typedef B. alias C. define D. struct Answer: A

Q45. Which of the following is the correct way to declare a multidimensional array in C?

A. int arr[3][3]; B. array int arr(3,3); C. int arr = [3][3]; D. declare arr[3][3] int; Answer: A

Q46. Which of the following is the correct way to declare a string in C?

A. char str[20]; B. string str[20]; C. char str = "Hello"; D. declare string str; Answer: A

Q47. What is the output of printf("%d", 10 != 5);?

A. 0 B. 1 C. True D. False Answer: B Explanation: 10 is not equal to 5, so the relational expression returns 1 (true).

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

A. strlen() B. strlength() C. strcount() D. strsize() Answer: A

Q49. Which keyword is used to define a constant variable in C?

A. const B. static C. define D. final Answer: A

Q50. Which of the following is the correct way to declare a pointer to an integer in C?

A. int p; B. int *p; C. pointer int p; D. int &p; Answer: B

Q51. Which of the following is the correct way to declare a function pointer in C?

A. int func(); B. int (func)(); C. function int func(); D. int func(); Answer: B

Q52. What is the output of printf("%d", 12 % 5);?

A. 2 B. 3 C. 5 D. 7 Answer: B Explanation: 12 divided by 5 leaves a remainder of 2.

Q53. Which function is used to release dynamically allocated memory in C?

A. free() B. delete() C. remove() D. release() Answer: A

Q54. Which keyword is used to declare a global variable in C?

A. global B. extern C. static D. register Answer: B

Q55. Which of the following is the correct way to declare a pointer to a structure in C?

A. struct student *s; B. student struct *s; C. struct *student s; D. pointer struct student s; Answer: A

Q56. Which of the following is the correct format specifier for printing a long integer in C?

A. %d B. %ld C. %li D. Both B and C Answer: D

Q57. What is the output of printf("%d", 15 & 7);?

A. 7 B. 15 C. 8 D. 0 Answer: A Explanation: Bitwise AND of 15 (1111) and 7 (0111) is 7 (0111).

Q58. Which function is used to read formatted input from a file in C?

A. fscanf() B. fread() C. fget() D. fscan() Answer: A

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

A. static B. extern C. register D. auto Answer: A

Q60. Which of the following is the correct way to declare a pointer to a float in C?

A. float p; B. float *p; C. pointer float p; D. float &p; Answer: B

Q61. Which of the following is the correct format specifier for printing a double in C?

A. %f B. %lf C. %d D. %ld Answer: B

Q62. What is the output of printf("%d", 20 >> 2);?

A. 5 B. 10 C. 20 D. 40 Answer: A Explanation: Right shift by 2 divides by 4; 20 ÷ 4 = 5.

Q63. Which function is used to reallocate memory in C?

A. malloc() B. calloc() C. realloc() D. free() Answer: C

Q64. Which keyword is used to declare a variable that is local to a block in C?

A. auto B. static C. extern D. register Answer: A

Q65. Which of the following is the correct way to declare a pointer to a character in C?

A. char p; B. char *p; C. pointer char p; D. char &p; Answer: B

Q66. Which of the following is the correct format specifier for printing an unsigned integer in C?

A. %d B. %u C. %i D. %ul Answer: B

Q67. What is the output of printf("%d", 9 | 3);?

A. 9 B. 11 C. 3 D. 12 Answer: B Explanation: Bitwise OR of 9 (1001) and 3 (0011) is 1011, which equals 11.

Q68. Which function is used to write a string to a file in C?

A. fputs() B. fwrite() C. fprintf() D. putfile() Answer: A

Q69. Which keyword is used to declare a variable that is stored in CPU registers for faster access?

A. register B. static C. auto D. extern Answer: A

Q70. Which of the following is the correct way to declare a pointer to a void in C?

A. void p; B. void *p; C. pointer void p; D. void &p; Answer: B

Q71. Which of the following is the correct format specifier for printing an unsigned long integer in C?

A. %lu B. %ld C. %u D. %d Answer: A

Q72. What is the output of printf("%d", 6 ^ 3);?

A. 5 B. 7 C. 9 D. 2 Answer: A Explanation: Bitwise XOR of 6 (110) and 3 (011) is 101, which equals 5.

Q73. Which function is used to read a character from a file in C?

A. fgetc() B. getc() C. getchar() D. Both A and B Answer: D

Q74. Which keyword is used to declare a variable that can be accessed across multiple files in C?

A. extern B. static C. global D. register Answer: A

Q75. Which of the following is the correct way to declare a pointer to a double in C?

A. double p; B. double *p; C. pointer double p; D. double &p; Answer: B

Q76. Which of the following is the correct format specifier for printing a short integer in C?

A. %d B. %hd C. %ld D. %u Answer: B

Q77. What is the output of printf("%d", ~5);?

A. -6 B. 5 C. -5 D. 6 Answer: A Explanation: Bitwise NOT inverts bits; for 5, the result is -6 in two’s complement representation.

Q78. Which function is used to write a character to a file in C?

A. fputc() B. putc() C. fprintf() D. Both A and B Answer: D

Q79. Which keyword is used to declare a variable that is local to a function in C?

A. auto B. static C. extern D. register Answer: A

Q80. Which of the following is the correct way to declare a pointer to a pointer in C?

A. int **p; B. int p; C. pointer int **p; D. int &&p; Answer: A

Q81. Which of the following is the correct format specifier for printing an unsigned short integer in C?

A. %hu B. %hd C. %u D. %d Answer: A

Q82. What is the output of printf("%d", 8 << 2);?

A. 16 B. 32 C. 8 D. 4 Answer: B Explanation: Left shift by 2 multiplies by 4; 8 × 4 = 32.

Q83. Which function is used to check the end of a file in C?

A. feof() B. eof() C. endfile() D. fileend() Answer: A

Q84. Which keyword is used to declare a variable that is volatile in C?

A. volatile B. static C. extern D. register Answer: A

Q85. Which of the following is the correct way to declare a pointer to a function returning int in C?

A. int f(); B. int (f)(); C. function int f(); D. int f();

Q86. Which of the following is the correct format specifier for printing an unsigned char in C?

A. %c B. %u C. %hhu D. %d Answer: C

Q87. What is the output of printf("%d", 7 && 0);?

A. 0 B. 1 C. True D. False Answer: A Explanation: Logical AND returns true only if both operands are non‑zero; here 7 && 0 = 0.

Q88. Which function is used to move the file pointer to a specific location in C?

A. fseek() B. ftell() C. rewind() D. movefile() Answer: A

Q89. Which keyword is used to declare a variable that cannot be modified in C?

A. const B. static C. final D. immutable Answer: A

Q90. Which of the following is the correct way to declare a pointer to a constant integer in C?

A. const int *p; B. int const *p; C. Both A and B D. int *const p; Answer: C

Q91. Which of the following is the correct format specifier for printing a long double in C?

A. %Lf B. %lf C. %f D. %ld Answer: A

Q92. What is the output of printf("%d", 0 || 1);?

A. 0 B. 1 C. True D. False Answer: B Explanation: Logical OR returns true if at least one operand is non‑zero; here 0 || 1 = 1.

Q93. Which function is used to determine the current position of the file pointer in C?

A. ftell() B. fseek() C. rewind() D. fpos() Answer: A

Q94. Which keyword is used to declare a variable that is constant and cannot be changed in C?

A. const B. static C. final D. immutable Answer: A

Q95. Which of the following is the correct way to declare a pointer to a constant pointer in C?

A. int *const p; B. const int *p; C. int const *p; D. Both A and B Answer: A

Q96. Which of the following is the correct format specifier for printing a hexadecimal integer in C?

A. %x B. %X C. Both A and B D. %h Answer: C

Q97. What is the output of printf("%d", 5 && 5);?

A. 0 B. 1 C. True D. False Answer: B Explanation: Logical AND returns true if both operands are non‑zero; here 5 && 5 = 1.

Q98. Which function is used to reset the file pointer to the beginning of a file in C?

A. rewind() B. fseek() C. ftell() D. reset() Answer: A

Q99. Which keyword is used to declare a variable that is defined only once in C?

A. static B. const C. extern D. register Answer: A

Q100. Which of the following is the correct way to declare a pointer to a constant integer pointer in C?

A. const int *const p; B. int const *const p; C. Both A and B D. int *const p; Answer: C

Labels

C Programming MCQs

Computer Science Questions

Engineering Exam Prep

Competitive Exams Practice

Aptitude and Technical MCQs

Programming Interview Questions

General Knowledge in C

 Hashtags

#CProgramming

#CProgrammingMCQs

#ComputerScienceMCQs

#EngineeringMCQs

#ExamPreparation

#CompetitiveExams

#StudyTips

#TechnicalMCQs

#CodingQuestions

#ProgrammingMCQs

#InterviewPreparation

#AptitudeQuestions

#ITExamPrep

#SoftwareEngineeringMCQs

#CSExamPreparation

#MCQJourney

#OnlineLearning

#PlacementPreparation

#CodingMCQs

#GeneralKnowledgeMCQs





Post a Comment

0 Comments