Bird
0
0

Which of the following format specifiers is used to print a string in printf or sprintf?

easy📝 Conceptual Q2 of 15
PHP - Output and String Handling
Which of the following format specifiers is used to print a string in printf or sprintf?
A%d
B%c
C%s
D%f
Step-by-Step Solution
Solution:
  1. Step 1: Identify the string format specifier

    The %s specifier is used to print strings in printf or sprintf.
  2. Step 2: Differentiate from other specifiers

    %c is for single characters, %d for integers, %f for floats, so %s is correct for strings.
  3. Final Answer:

    %s -> Option C
  4. Quick Check:

    Format specifier %s = string [OK]
Quick Trick: Use %s to print strings in printf/sprintf [OK]
Common Mistakes:
  • Using %d or %f for strings
  • Confusing %c with %s
  • Omitting the % sign

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes