-->

Facebook

Jasper Roberts - Blog

Tuesday, October 14, 2014

The getchar() & putchar() functions

getchar()

-   reads only single character at a time.
-   It can be used in the loop if there is need to read more than one characters from the screen.


putchar() 

-   This function puts only single character at a time.

-   It can be used in the loop if you want to display more than one character on the screen.

- Example:

#include<conio.h>
#include<stdio.h>

int main()
{
     int c;

     clrscr();
     printf(“Enter the value:”);
     c = getchar();

     printf(“\n Entered Value is:”);
     putchar(c);    
    
     return 0;   

}

OUTPUT:

       Enter the value: 20
       Entered Value is: 20     


1 comment: