SINGLE CHARACTER INPUT - THE getchar( ) FUNCTION
Single characters can be entered in to the computer using the C library function getchar( ). The getchar function is a part of the standard C Language i/o Library. It returns a single character from a standard input device. The function does not require any arguments, though a pair of empty parentheses must follow the word getchar.
In general terms a reference to the getchar function is written as:-
character variable = getchar( );
Here character variable refers to some previously declared character variable
SINGLE CHARACTER OUTPUT-THE putchar( ) FUNTION
The putchar( ) function, like getchar( ), is a part of the standard C language i/o library. It transmits a single character to a standard output device. The character being transmitted will normally be represented as a character- type variable. It must be expressed as an argument to the function enclosed in parentheses following the word putchar.
In general a reference to the putchar function is written as . putchar( char var )
e.q A C-Program contains the following statement :
char C;
_
_
_
_
putchar(C);
The first statement declares that C is a character type variable. The second statement causes the current value of C to be transmitted to the standard output device.
ENTERING INPUT DATA THE scanf( ) FUNTION
Input data can be entered into the computer from a standard input device by means of the C
library function scanf().
In general terms, the scanf function is written as scanf(Control string, arg1,arg2,.....,argn)
Here control string refers to a string containing certain required formatting information, and arg1, arg2,...arg n are arguments that represent the individual input data items. The argu- ments represent pointers that indicate the addresses of the data item within the computers memory.
The control string comprises individual groups of characters with one character group for each input data item. Each character group must begin with a a percent sign( % ). In its simplest form a single character group will consist of the percent sign, followed by a conver- sion character which indicates the type of the corresponding data item.
COMMONLY USED CONVERSION CHARACTERS FOR DATA INPUT
Single characters can be entered in to the computer using the C library function getchar( ). The getchar function is a part of the standard C Language i/o Library. It returns a single character from a standard input device. The function does not require any arguments, though a pair of empty parentheses must follow the word getchar.
In general terms a reference to the getchar function is written as:-
character variable = getchar( );
Here character variable refers to some previously declared character variable
SINGLE CHARACTER OUTPUT-THE putchar( ) FUNTION
The putchar( ) function, like getchar( ), is a part of the standard C language i/o library. It transmits a single character to a standard output device. The character being transmitted will normally be represented as a character- type variable. It must be expressed as an argument to the function enclosed in parentheses following the word putchar.
In general a reference to the putchar function is written as . putchar( char var )
e.q A C-Program contains the following statement :
char C;
_
_
_
_
putchar(C);
The first statement declares that C is a character type variable. The second statement causes the current value of C to be transmitted to the standard output device.
ENTERING INPUT DATA THE scanf( ) FUNTION
Input data can be entered into the computer from a standard input device by means of the C
library function scanf().
In general terms, the scanf function is written as scanf(Control string, arg1,arg2,.....,argn)
Here control string refers to a string containing certain required formatting information, and arg1, arg2,...arg n are arguments that represent the individual input data items. The argu- ments represent pointers that indicate the addresses of the data item within the computers memory.
The control string comprises individual groups of characters with one character group for each input data item. Each character group must begin with a a percent sign( % ). In its simplest form a single character group will consist of the percent sign, followed by a conver- sion character which indicates the type of the corresponding data item.
COMMONLY USED CONVERSION CHARACTERS FOR DATA INPUT
Conversion character | Meaning |
c | data item is a single character |
d | data item is a decimal integer |
f | data item is a floating point value |
h | data item is a short integer |
I | data item is a decimal, hexadecimal or octal integer |
o | data item is an octal integer |
s | data item is a string followed by white space character |
u | data item is an unsigned decimal integer |
x | data item is a hexadecimal integer |
e.q of scanf function
# include "stdio.h"