Bird
0
0

You want to read two integers from the user separated by a space. Which scanf statement correctly does this?

hard📝 Application Q8 of 15
C - Input and Output
You want to read two integers from the user separated by a space. Which scanf statement correctly does this?
Ascanf("%d%d", a, b);
Bscanf("%d,%d", &a, &b);
Cscanf("%d %d", a, b);
Dscanf("%d %d", &a, &b);
Step-by-Step Solution
Solution:
  1. Step 1: Check format string for two integers

    The format string should have two %d separated by space to read two integers.
  2. Step 2: Confirm passing addresses

    Both variables must be passed by address using &a and &b.
  3. Final Answer:

    scanf("%d %d", &a, &b); -> Option D
  4. Quick Check:

    Two ints: use "%d %d" and &variables [OK]
Quick Trick: Use "%d %d" and &variables to read two ints [OK]
Common Mistakes:
  • Forgetting & before variables
  • Using comma in format string incorrectly
  • Passing variables instead of addresses

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Quizzes