Bird
0
0

What will be the output of this C code?

medium📝 Predict Output Q13 of 15
C - Input and Output
What will be the output of this C code?
#include <stdio.h>
int main() {
  int age;
  printf("Enter your age: ");
  scanf("%d", &age);
  printf("You are %d years old.\n", age);
  return 0;
}
ANo output
BYou are 0 years old.
CSyntax error
DYou are [input number] years old.
Step-by-Step Solution
Solution:
  1. Step 1: Understand input with scanf()

    The program asks for age and reads an integer from the user using scanf.
  2. Step 2: Understand output with printf()

    It prints the entered age using printf with %d placeholder.
  3. Final Answer:

    You are [input number] years old. -> Option D
  4. Quick Check:

    Input number is printed back as output [OK]
Quick Trick: scanf reads input; printf shows it [OK]
Common Mistakes:
  • Ignoring that scanf waits for user input
  • Expecting fixed output without input
  • Confusing scanf and printf usage

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Quizzes