Bird
0
0

What will be the output of this code?

medium📝 Predict Output Q5 of 15
C - Input and Output
What will be the output of this code?
char ch = 'A';
printf("Character: %c, ASCII: %d", ch, ch);
ACharacter: A, ASCII: A
BCharacter: A, ASCII: 65
CCharacter: %c, ASCII: %d
DCharacter: 65, ASCII: A
Step-by-Step Solution
Solution:
  1. Step 1: Understand %c and %d with char variable

    %c prints the character itself, %d prints its ASCII integer value. 'A' has ASCII 65.
  2. Step 2: Substitute values in printf

    The output becomes "Character: A, ASCII: 65".
  3. Final Answer:

    Character: A, ASCII: 65 -> Option B
  4. Quick Check:

    Char as %c and ASCII as %d = Character: A, ASCII: 65 [OK]
Quick Trick: Use %c for char, %d for ASCII integer in printf [OK]
Common Mistakes:
  • Mixing %c and %d
  • Printing ASCII as char
  • Forgetting single quotes for char

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Quizzes