Bird
0
0

How would you print a percentage sign (%) using printf in C?

hard📝 Application Q9 of 15
C - Input and Output
How would you print a percentage sign (%) using printf in C?
Aprintf("%");
Bprintf("%%");
Cprintf("%percent");
Dprintf("\%");
Step-by-Step Solution
Solution:
  1. Step 1: Understand escaping % in printf

    Since % is a special character in format strings, to print a literal % you use %%.
  2. Step 2: Analyze other options

    printf("%percent"); is invalid syntax, printf("%"); is incomplete, printf("\%"); uses backslash which is not recognized for % in printf.
  3. Final Answer:

    printf("%%"); -> Option B
  4. Quick Check:

    Use %% to print % literally in printf [OK]
Quick Trick: Use double %% to print a single % in printf [OK]
Common Mistakes:
  • Using single %
  • Trying backslash escape
  • Writing %percent

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Quizzes