Showing posts with label AD.getchar and putchar function. Show all posts
Showing posts with label AD.getchar and putchar function. Show all posts

Getchar function

Getchar function scans the single character from user it will only take 1 character it will terminate on pressing "Enter". Let us see syntax...:

Syntax:

variable=getchar();

Example Program for Getchar function:


#include<stdio.h>
#include<conio.h>
main()
{
     char c;
     clrscr();
     printf("Enter Any character: ");
     c=getchar();
     printf("\nYou have Entered %c",c);
     getch();

}

Putchar function

putchar function is used to print the character on screen.it is also used to print the character stored in any variable.Let us see syntax of putchar:

Syntax:

putchar(variable or character);

Example for putchar function:

#include<stdio.h>
#include<conio.h>
main()
{
     char a;
     clrscr();
     printf("Enter Any character: ");
     a=getchar();
     printf("\nYou have entered: ");
     putchar(a);
     getch();

}