Example of printf

In this example, we are printing the string “Hello Geek!” in the output using printf() function. In printf() function what we will write inside the double quotes (” “) is printed in the output.

C




// C program to illustrate the use of printf function
#include <stdio.h>
 
int main()
{
    // using printf to print "Hello Geek!"
    printf("Hello Geek!");
 
    return 0;
}


Output

Hello Geek!

printf in C

In C language, printf() function is used to print formatted output to the standard output stdout (which is generally the console screen).  The printf function is a part of the C standard library <stdio.h> and it can allow formatting the output in numerous ways.

Similar Reads

Syntax of printf

printf ( "formatted_string", arguments_list);...

Parameters

formatted_string: It is a string that specifies the data to be printed. It may also contain a format specifier to print the value of any variable such as a character and an integer. arguments_list: These are the variable names corresponding to the format specifier....

Return Value

printf() returns the number of characters printed after successful execution. If an error occurs, a negative value is returned....

Example of printf

In this example, we are printing the string “Hello Geek!” in the output using printf() function. In printf() function what we will write inside the double quotes (” “) is printed in the output....

Formatting in C printf

...

Examples of printf() in C

In C, a value can be a character type, integer type, float type, and so on. To display and format these values using printf, we have format specifiers that are used in the formatted string. These format specifiers start with the percentage symbol ‘%’....