Thursday, 11 August 2016

Formatted Input and output functions for character

Formatted Input and output functions for character

#include<stdio.h>
void main()
{
          char ch;
          printf("\n Enter a character: ");
          scanf("%c", &ch);                          //formatted input
          printf("\n Entered character is: ");
          printf("%c", ch);                          //formatted output
}

Output:

1) Enter a character: h
    Entered character is: h

2) Enter a character: hii
    Entered character is: h