Bird
0
0

Which of the following correctly reads two integers and prints their sum in C?

easy📝 Conceptual Q1 of 15
C - Input and Output
Which of the following correctly reads two integers and prints their sum in C?
Aint a, b; scanf("%d %d", &a, &b); printf("%d", a + b);
Bint a, b; scanf("%d", a, b); printf("%d", a + b);
Cint a, b; scanf("%d %d", a, b); printf("%d", a + b);
Dint a, b; scanf("%d %d", &a, &b); printf("%d %d", a, b);
Step-by-Step Solution
Solution:
  1. Step 1: Understand scanf usage for multiple inputs

    scanf requires addresses of variables using & to store input values correctly.
  2. Step 2: Check printf for correct output

    Printing the sum requires one %d and the expression a + b.
  3. Final Answer:

    Correctly reads two integers and prints their sum. -> Option A
  4. Quick Check:

    Correct scanf and printf usage = int a, b; scanf("%d %d", &a, &b); printf("%d", a + b); [OK]
Quick Trick: Use & with variables in scanf for input [OK]
Common Mistakes:
  • Forgetting & in scanf
  • Using wrong format specifiers
  • Printing variables without format specifiers

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Quizzes