In the C programming language, which function prints formatted output to the screen?

The story behind the answer

In the C programming language, printf prints formatted output to the screen. Its name is short for “print formatted,” and the function writes text to standard output, normally the terminal or console.

The function uses a format string containing ordinary text and conversion specifiers such as %d for an integer, %f for floating-point output, and %s for a string. For example, printf("Age: %d", age) combines fixed text with the value stored in age. Programs normally make printf available by including the standard header <stdio.h>.

The alternatives describe different operations. getchar reads one character from input, scanf reads formatted input, and puts writes a string followed by a newline. printf is more flexible because it can combine several values and control their representation, such as decimal, hexadecimal, field width, or precision.

The routine originated in Unix-era C development and became part of the C standard library. It also helped popularize the classic “Hello, world!” beginner program. Programmers must match format specifiers to argument types; mismatches can produce undefined behavior and, in unsafe code, security vulnerabilities.

Source: Wikipedia · fact-checked Aug. 2026

Add question to a list

Choose a list to keep this question in: