Thursday, December 10, 2009

3.2 SINGLE CHARACTER OUTPUT- THE putchar FUNCTION

Single characters can be displayed (i.e. written out of the computer) using the c library function putchar.The function is complementary to the character input function getchar.

In general a function reference would be written as

putchar(character variable)

where character variable refers to some previously mentioned character variable.

Below is a simple example which takes a character as input from the user and displays the equivalent uppercase character.

/*lowercase to uppercase conversion*/
#include
#include

main()

{

char ch;
printf("Enter any character value");
ch=getchar();
printf("The equivalent uppercase character is ");
putchar(toupper(ch));

}

No comments:

Post a Comment