Bird
0
0

Write a C program snippet that reads two integers and prints their sum and product separated by a space. Which code correctly does this?

hard📝 Application Q15 of 15
C - Input and Output
Write a C program snippet that reads two integers and prints their sum and product separated by a space. Which code correctly does this?
Aint a, b;<br>scanf("%d %d", &a, &b);<br>printf("%d %d", a + b, a * b);
Bint a, b;<br>scanf("%d %d", a, b);<br>printf("%d %d", a + b, a * b);
Cint a, b;<br>scanf("%d %d", &a, &b);<br>printf("%d %d", a - b, a / b);
Dint a, b;<br>scanf("%d %d", &a, &b);<br>printf("%d %d", a * b, a + b);
Step-by-Step Solution
Solution:
  1. Step 1: Check input reading correctness

    scanf must use &a and &b to read two integers correctly.
  2. Step 2: Check output matches sum and product

    printf should print sum (a + b) first, then product (a * b) separated by space.
  3. Final Answer:

    int a, b; scanf("%d %d", &a, &b); printf("%d %d", a + b, a * b); -> Option A
  4. Quick Check:

    scanf with & and printf sum then product [OK]
Quick Trick: Print sum first, product second with correct scanf [OK]
Common Mistakes:
  • Forgetting & in scanf
  • Swapping sum and product order
  • Using wrong operators in printf

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Quizzes