Bird
0
0

What will this C program print?

medium📝 Predict Output Q5 of 15
C - Basics and Execution Environment
What will this C program print?
#include <stdio.h>
int main() {
    int x = 10;
    int y = 4;
    printf("%d", x / y);
    return 0;
}
A2.5
B2
C4
DError
Step-by-Step Solution
Solution:
  1. Step 1: Understand integer division in C

    Dividing two integers truncates the decimal part.
  2. Step 2: Calculate 10 divided by 4

    10 / 4 equals 2.5, but integer division results in 2.
  3. Final Answer:

    2 -> Option B
  4. Quick Check:

    Integer division truncates decimals = 2 [OK]
Quick Trick: Integer division drops decimals in C [OK]
Common Mistakes:
  • Expecting floating-point result
  • Confusing with other languages' division

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Quizzes