Char: Converting uppercase to lowercase : Char « Data Type « C / ANSI-C






Char: Converting uppercase to lowercase

Char: Converting uppercase to lowercase

/* Char: Converting uppercase to lowercase */
#include <stdio.h>

void main()
{
   char letter = 0;                         /* Stores a character */

   printf("Enter an uppercase letter:");  
   scanf("%c", &letter);                    /* Read a character   */

   /* Check whether the input is uppercase*/
   if(letter >= 'A')                    /* Is is A or greater?   */
     if (letter <= 'Z')                 /* and is it Z or lower? */
     {                                  /* It is upper case      */
       letter = letter - 'A'+ 'a';      /* Convert from upper to lower case */
       printf("An uppercase %c\n", letter);
     }
     else                               /* It is not an upper case letter */
       printf("A capital letter please.\n");
}


           
       








Related examples in the same category

1.Encrypting a password
2.Char: to upper case
3.Characters and numbers: outputCharacters and numbers: output
4.Use data type: char
5.Char to lower case
6.maximum and minimum value of char
7.Get char and change it to float
8.Double check before erasing
9.Assing int value to a char type variable
10.Output char to the console
11.For loop with char as the loop condition