The
program segment given below converts an uppercase letter to lowercase.
As the C language allows arithmetic operations on characters, we can use
expression such as ‘a’ – ‘A’,
‘g’ – ‘G’, etc. instead of literal 32.
‘g’ – ‘G’, etc. instead of literal 32.
#include <stdio.h> #include<conio.h> void main() { char letter = 0; printf("Enter an uppercase letter: It); scanf("%c", &letter); if(letter >= 'A') if (letter <= 'Z') { letter = letter - 'A'+ 'a'; printf("An uppercase %c\n", letter); } else printf("A capital letter please.\n"); getch(); } OUTPUT: Enter an uppercase letter: S An uppercase s
0 comments:
Post a Comment