Bird
0
0

What does the following C code do?

easy📝 Conceptual Q11 of 15
C - Input and Output
What does the following C code do?
int a, b;
scanf("%d %d", &a, &b);
printf("%d %d", a, b);
APrints two integers without reading input.
BReads one integer and prints it twice.
CReads two integers from input and prints them in the same order.
DReads two integers but prints only the first one.
Step-by-Step Solution
Solution:
  1. Step 1: Understand scanf with multiple inputs

    The scanf function reads two integers from the user input and stores them in variables a and b.
  2. Step 2: Understand printf with multiple outputs

    The printf function prints the values of a and b in the same order they were read.
  3. Final Answer:

    Reads two integers from input and prints them in the same order. -> Option C
  4. Quick Check:

    scanf and printf with two %d = same two integers [OK]
Quick Trick: Match each %d with a variable and & in scanf [OK]
Common Mistakes:
  • Forgetting & before variables in scanf
  • Mixing order of variables in printf
  • Using wrong format specifiers

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Quizzes