printf Format Specifiers
Print values precisely.
What printf Does
printf writes formatted text to the screen. Format specifiers starting with % are replaced by your values.
#include <stdio.h>
int main(void) {
printf("Hello, world!\n");
return 0;
}Printing Integers with %d
Use %d for a signed decimal integer.
#include <stdio.h>
int main(void) {
int age = 30;
printf("Age: %d\n", age);
return 0;
}All lessons in this course
- printf Format Specifiers
- scanf and Input
- Width, Precision, Flags
- Common I/O Pitfalls