2. IN-Put Statement
• An input/output statement or io statement is
a portion of a program that instructs a
computer how to read and process
information.
• It use to gather information from an input
device, or sending information to an output
device.
Copyrights By Tanveer Malik
3. IN-Put Statements
• Scanf () Function.
• Gets() Function.
• Getchar(), getch(), and getch Function.
• Input using Cin
Copyrights By Tanveer Malik
4. Scanf()
• Scanf is a inbuilt library functions in C
programming language which is available in C
library by default.
• In C programming language, scanf() function is
used to read character, string, numeric data
from keyboard.
• Consider below example program where user
enters a character. This value is assigned to
the variable “ch” and then displayed.
Copyrights By Tanveer Malik
6. Gets()
• The C library function char *gets(char *str)
reads a line from stdin and stores it into the
string pointed to by str.
• It stops when either the newline character is
read or when the end-of-file is reached,
whichever comes first.
Copyrights By Tanveer Malik
8. Getc()
• It reads a single character from a given input
stream and returns the corresponding integer
value on success.
Syntax:
• int getc(FILE *stream);
Copyrights By Tanveer Malik
10. Getchar()
• The difference between getc() and getchar() is
getc() can read from any input stream,
• but getchar() reads from standard input.
• So getchar() is equivalent to getc(stdin).
Syntax:
• int getchar(void);
Copyrights By Tanveer Malik
12. Getch()
• getch() is a nonstandard function.
• It is present in conio.h header file.
• Which is mostly used by MS-DOS compilers
like Turbo C.
Syntax:
• int getch();
Copyrights By Tanveer Malik