C Input and Output

What is C Input and Output?

In this tutorial, you are going to learn about C Input and Output.  C Language provides mechanisms to take input from users and display their outputs.  C Input refers to storing the value in the memory after its execution. C output in the other hand displays such values stored in memory. There are various built-in functions used in C which is used to perform the supplying input data to the program and obtaining the output results from the program.

In this tutorial, you will learn about different built-in functions which can be used for providing inputs from the user to the computer. They also support in displaying the outputs in the screen and their respective header files.

scanf() and printf() functions

scanf() and printf() functions definitions are contained by the header file stdio.h which is used for taking input from the user and displaying output on the screen respectively.

The program above illustrates a simple program which takes input from the user and displays the output. The scanf() function takes an input from the user as per their type specified. On the other hand, the printf() function will print the parameters that are passed into the program in the console screen.

You might have been wondering about what is the purpose of using “%d” inside the printf() and scanf() functions. They are format specifiers. Format specifiers are used while giving input and displaying an output of the program. It is a mechanism to tell the compiler about what data are going to be used in the variables and the type of data to be printed.  The table below lists some of the most used format specifiers in C with their respective uses.

 %fIt is used for scanning and printing floating point number.
 %dIt is used for scanning and printing signed decimal number.
 %SIt is used for scanning and printing character string.
 %cIt is used for scanning and printing a character.





SHARE C Input and Output

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *