printf()
Try it yourself →Writes formatted output.
Syntax
printf("format", ...)Description
Writes with placeholders: %d integer, %f float, %c character, %s text. Add \n for a new line.
Example
#include <stdio.h>
int main() {
printf("Number: %d\n", 42);
printf("Text: %s\n", "Alex");
return 0;
}Expected output
Number: 42 Text: Alex
When to use?
Showing results, debugging.
Common mistakes
- ⚠️ New lines are not automatic; don't forget to add \n.
- ⚠️ Printing text with %d or numbers with %s is undefined behavior.