Use getchar() and putchar() to input characters from the keyboard and display them in reverse case. - C Data Type

C examples for Data Type:char

Description

Use getchar() and putchar() to input characters from the keyboard and display them in reverse case.

Demo Code

#include <stdio.h>
#include <ctype.h>

int main(void)

{
   char ch;//w  ww .  j  a v  a  2 s  .c  o m

   printf("Enter some text (type a period to quit).\n");
   do {
      ch = getchar();

      if (islower(ch)) ch = toupper(ch);
      else ch = tolower(ch);

      putchar(ch);

   } while (ch != '.');


   return 0;
}

Result


Related Tutorials