Printf Function

The printf is a standard C library function used for the formatted output. It is not a statement-like return but rather a function that takes a format string and a variable number of arguments. It displays formatted data to the console or other output streams and does not pass data between the functions.

Syntax

printf("format string", argument1, argument2, ...);

Example

C




// C program to illustrate printf
#include <stdio.h>
 
// function that prints value
void foo() { printf("In the function"); }
 
// driver code
int main()
{
    foo();
    return 0;
}


Output

In the function

Difference between return and printf in C

In C programming, return and print serve fundamentally different purposes and they are used in distinct contexts to achieve specific tasks. Let’s see each of them and see what are their functions and differences.

Similar Reads

1. Return Statement

In C, return is a statement used within a function to terminate the function’s execution and return a value to the caller. It is used to pass data back from the function to the calling code....

2. Printf Function

...

Difference between return and printf in C

The printf is a standard C library function used for the formatted output. It is not a statement-like return but rather a function that takes a format string and a variable number of arguments. It displays formatted data to the console or other output streams and does not pass data between the functions....

Contact Us