Program to convert an Uppercase character into a Lowercase character and Lowercase character into an Uppercase character.
Converting an Uppercase character into a Lowercase character and a Lowercase character into an Uppercase character: -
_________________________________________
C program to convert an uppercase character into a lowercase character: -
The program shown below will read an uppercase character from standard input and convert it into its corresponding lowercase character.
Program:-
#include <stdio.h>
void main() {
char ch;
printf("uppercase character : ");
scanf(" %c", &ch);
ch = ch + 32;
printf("lowercase character : %c\n", ch);
}
Output: -
uppercase character : D
lowercase character : d
Fig: Converting an uppercase character into a lowercase character |
Note: -
ASCII values for uppercase alphabets are from 65('A') to 90('Z') and the lowercase alphabets are from 97('a') to 122('z').
Therefore the difference between an uppercase and lowercase character is 32, adding 32 to the uppercase character will give its corresponding lowercase character.
_________________________________________________________________________
C program to convert a Lowercase character into an Uppercase character: -
The program shown below will read a Lowercase character from standard input and convert it into its corresponding Uppercase character.
Program:-
#include <stdio.h>
void main() {
char ch;
printf("lowercase character : ");
scanf(" %c", &ch);
ch = ch - 32;
printf("uppercase character : %c\n", ch);
}
Output: -
lowercase character : d
uppercase character : D
Fig: Converting a lowercase character into an uppercase character |
Comments
Post a Comment
Leave your Quires here!