0Pricing
C Academy · Lesson

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

  1. printf Format Specifiers
  2. scanf and Input
  3. Width, Precision, Flags
  4. Common I/O Pitfalls
← Back to C Academy