Input output introduction

Input : data provided to a program.
Output : data provided by a program.

The basic input/output function are getchar, putchar, gets, puts, scanf, printf.getchar and putchar : Single Charactergetchar function : Single Character Input
The getchar function returns a singlecharacter. putchar function : SingleCharacter Output Single characters can be displayed using the putchar function.

Example of getchar and putchar :

#include <stdio.h>
int main( )
{
    int c;

    printf( "Enter a single character :");
    c = getchar( );

    printf( "\nEntered Character is : ");
    putchar( c );

    return 0;
}

Output :
Enter a single character : a
Entered Character is : a

Explanation :
When you enter a single character or string as input in getchar function, the putchar function will only going to display the first character from the entered input. Because getchar and putchar function are single character input and output function.

Post a Comment

0 Comments