Input output Statement in C

In this tutorial, we will study the input output statement in c, what is scanf, and printf. so let us start.

What are the input output statements in c?

In the C Language to process an input-output statement, there are two ways or processes. Input means taking the data from the user that will be used in the program and output means the data that will be delivered to the user by displaying it on the monitor.

By using the console we can give input as well as take output. The Console is a black window which is a display monitor and an input device. The console on the execution of the program shows the output of the code.
By the use of Console different-different types of data, input can be given. like

  1. String
  2. Number
  3. Characters
  4. All the primitive types of data ( float, double, long, etc ).

For the Console, there are 2 Standard devices.

  1. Keyboard:- in the C program the keyboard is used to give the input
  2. Monitor:- in the C program the monitor displays the output

C Console Input-output Functions

By using the Console we can perform I/O functions easily by using the built-in functions provided by the c. For Example:-

What is a scanf()?

This is an input function. The standard input-output header file contains the definition of a scanf. This function uses the keyboard to take the input in the program. By using this user can give any primitive types of data input. For Example:-

scanf(“%d”,& variable-name);

In this syntax, the %d is a format specifier which tells the compiler about the input data type. For each type in the C programming language, we have a format specifier that is already defined.

What is a printf()?

printf() is an output function. The standard input-output header file contains the definition of a printf. Printf stands for print formatted. It is used to print formatted output. The user uses the monitor for showing the output. By the use of this function, we can show various primitive types of data to the user. For Example:-


In this function, we can print the string directly as well as we can pass any variable whose value we wish to print. The String is written in the double quotes (“ “). We can pass both the spring as well as the variable if we wish to. To generate a new line we can use”\n” in the c printf statement.

%d = Scan or print an integer as a signed decimal number

%f = Scan or print a floating-point number

%c = To scan or print a character

%s = To scan or print a character string. The scanning ends at whitespace

The %d is for the integer. The %f is for the floating numbers. The %c is for the character. The %s is for the string.

input output statement in c




Use My Notes is an Education Website for providing all Technical course material.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Continuous Deployment of an AWS API Gateway using Bitbucket Pipelines

Union in C Programming

Performance Optimization Techniques

AR teams — Best practices for collaborating over Spark AR projects

Migrate Data from AWS S3 to Azure Blob

CS373 Spring 2022: Alejandro Cantu: Final Entry

Blazor Framework: Revolution in .NET Core Development

Migrating to Java 11 while maintaining a Java 8 client library

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Use My Notes

Use My Notes

Use My Notes is an Education Website for providing all Technical course material.

More from Medium

C Programming Language Algorithm Examples/Exercises

C — Static libraries


Examining the Mechanics of Singleton Pattern in C++