In order to interact with a C Program a programmer may design it with certain input and output commands. This lets user to input value at will and get corresponding results. All of that is possible because of some dedicated predefined functions.

Input/Output Commands in C

C language has several predefined library functions to perform input and output tasks.
Here, I have mentioned few of them, in details about their functions in a program.

Input/Output Statements in C:

1. scanf(): It is used to take input from user. scanf() is used to read input values of variables by using input devices. The syntax of scanf() is given below:

scanf("control_string contro string...", & variable name1, &variable name2, ..., & variable name n);

2. printf(): It is used to display the output. printf() is used to print values of variable by using the output devices. The syntax of printf() is given below:

printf("control_string contro string...", & variable name1, &variable name2, ..., & variable name n);

3. getchar(): It is a character input/output function which reads a character from Keyboard at a time. The syntax is as follows:

char variable=getchar();

4. getch(): It is a character input/output function which reads a character from Keyboard and it does not expect the Enter key press. The syntax is as follows:

char variable=getch();

5. getche(): It is a character input/output function which reads a character from Keyboard and echoes it. The syntax is as follows:

char variable=getche ();

6. gets(): It is a character input/output function which reads a line or a string of characters including white spaces from the Keyboard. The syntax is as follows:

gets(char variable);

7. putchar(): It is a character input/output function which writes a character to monitor screen at a time. The syntax is as follows:

putchar(charvariable);

8. putch(): It is a character input/output function which writes or displays a line or a string of characters including white spaces on the monitor screen. The syntax is as follows:

puts(character string variable);

9. clrscr(): It is a character input/output function which is used to clear the monitor screen. The syntax is as follows:

clrscr();


Books I Prefer:



  

I hope this article was helpful to understand different Input/Output statements in C! Comment below, if you've got any question. Head back soon for another interesting article on C Programming.