#1 India's Top IT Training Institute
×

About Uncodemy

Know more about who we are and what we stand for.

About Us

About Us

Discover our mission to equip individuals with essential IT skills and industry expertise.

Read More →
UnCodeMy Gallery

UnCodeMy Gallery

Explore highlights from our IT training sessions and success stories.

Read More →
Mentors

Mentors

Meet the industry experts who train and guide you through your course.

Read More →
Free Resources

Free Resources

Free tutorials, interview questions, tools and calculators to help you learn.

Explore →
×

Free Resources

Learn, practice and plan your career — bilkul free.

Tutorials

Tutorials

Step-by-step written tutorials to learn any technology at your own pace.

Read More →
Free Counselling

Free Counselling

Book a free video counselling session and pick the right course for you.

Read More →
Online Compiler

Online Compiler

Write, run and test your code online — no setup required.

Read More →
Interview Prep

C Programming MCQ – C Language Multiple Choice Questions with Answers

Practice with C MCQs

Multiple choice questions are a great way to test your conceptual understanding of C programming quickly.

Sample MCQ 1

Which of the following is the correct format specifier for a float in printf()?
a) %d   b) %c   c) %f   d) %s
Answer: c) %f

Sample MCQ 2

What is the size of an int on most 32-bit systems?
a) 2 bytes   b) 4 bytes   c) 8 bytes   d) 1 byte
Answer: b) 4 bytes

Sample MCQ 3

Which function is used to allocate memory dynamically and initialize it to zero?
a) malloc()   b) calloc()   c) realloc()   d) free()
Answer: b) calloc()

Practicing MCQs across data types, operators, loops, functions, and pointers builds strong exam and interview readiness.

Output-Prediction MCQs With Explanations

Many exams and written interview rounds show a short program and ask for its output. Try each one before reading the answer.

MCQ 4: Post-increment

int x = 5;
printf("%d", x++ + 2);
  • a) 7
  • b) 8
  • c) 6
  • d) Compile error

Answer: a) 7. Post-increment uses the current value (5) in the expression and only then increases x to 6.

MCQ 5: Pointer arithmetic

int a[] = {10, 20, 30, 40};
int *p = a;
printf("%d", *(p + 2));
  • a) 12
  • b) 20
  • c) 30
  • d) Address of a[2]

Answer: c) 30. Adding 2 to a pointer moves it two elements forward, not two bytes, so it points to a[2].

MCQ 6: The stray semicolon

int i;
for (i = 0; i < 5; i++);
printf("%d", i);
  • a) 0 1 2 3 4
  • b) 4
  • c) 5
  • d) Infinite loop

Answer: c) 5. The semicolon after the for makes the loop body empty. The loop runs until i becomes 5, then the print runs once.

MCQ 7: sizeof a string array

char s[] = "hello";
printf("%zu %zu", sizeof(s), strlen(s));
  • a) 5 5
  • b) 6 5
  • c) 5 6
  • d) 8 5

Answer: b) 6 5. The array stores the five letters plus the terminating '\0', while strlen counts only the visible characters.

MCQ 8: Integer division

int a = 7, b = 2;
float r = a / b;
printf("%.1f", r);
  • a) 3.5
  • b) 3.0
  • c) 4.0
  • d) Error

Answer: b) 3.0. Both operands are integers, so the division happens in integer form first and gives 3. Write (float)a / b to get 3.5.

Concept MCQs on Storage and Libraries

MCQ 9

Which storage class keeps a local variable's value between function calls?

  • a) auto
  • b) register
  • c) static
  • d) extern

Answer: c) static. A static local is created once and keeps its last value, which is handy for counting how often a function runs.

MCQ 10

Which header must be included to use strcpy() and strcmp()?

  • a) stdio.h
  • b) string.h
  • c) stdlib.h
  • d) ctype.h

Answer: b) string.h. Memory functions like malloc live in stdlib.h, and character tests like isdigit are in ctype.h.

MCQ 11

What does sizeof(char) return on every standard C compiler?

  • a) 1
  • b) 2
  • c) Depends on the system
  • d) 8

Answer: a) 1. The C standard defines sizeof(char) as exactly 1. Sizes of int and long, by contrast, depend on the platform, which is why MCQ 2 says "most systems".

Traps Examiners Like to Set

  • = versus ==: if (x = 0) assigns zero and the condition is always false.
  • Missing break in switch: execution falls through into the next case.
  • Character arithmetic: 'A' + 1 is the code for 'B', so printing it with %c shows B.
  • Operator precedence: *p++ increments the pointer, not the value it points to.
  • Undefined behaviour: expressions like i = i++ + ++i have no single correct output. A well-written exam avoids them, and "undefined" can itself be the right answer.

A Better Way to Practise

  1. Pick one topic at a time, such as pointers or loops.
  2. Answer on paper first, then run the code to check.
  3. For every wrong answer, write one line explaining the rule you missed.
  4. Revisit those notes before the exam instead of rereading whole chapters.

Ready to master real-world C Programming development?

Learn C Programming hands-on with mentor-led, live sessions.

Explore Course