Recall & Review
beginner
What is a format specifier in C?
A format specifier is a special sequence in a string that tells the program how to display or read data, like %d for integers or %f for floating-point numbers.
Click to reveal answer
beginner
What does the format specifier %d represent?
The %d specifier is used to print or read an integer (whole number) value.
Click to reveal answer
intermediate
How do you print a floating-point number with 2 decimal places in C?
Use %.2f in the format string. For example, printf("%.2f", 3.14159) prints 3.14.
Click to reveal answer
beginner
What format specifier is used to print a single character?
The %c specifier is used to print a single character.
Click to reveal answer
beginner
How do you print a string in C using format specifiers?
Use %s to print a string. For example, printf("%s", "hello") prints hello.
Click to reveal answer
Which format specifier is used to print an integer in C?
✗ Incorrect
%d is used for integers, %f for floats, %c for characters, and %s for strings.
How would you print the floating-point number 3.14159 with 3 decimal places?
✗ Incorrect
Use %.3f to specify 3 decimal places for a float.
What does the format specifier %c print?
✗ Incorrect
%c prints a single character.
Which format specifier is used to print a string?
✗ Incorrect
%s is used to print strings.
What will printf("%5d", 42); print?
✗ Incorrect
The %5d specifier prints the integer right-aligned in a field 5 characters wide, adding spaces before the number.
Explain what format specifiers are and give three examples with their uses.
Think about how you tell the program to print different types of data.
You got /4 concepts.
Describe how to control the number of decimal places when printing a floating-point number in C.
Focus on the dot and number inside the format specifier.
You got /3 concepts.