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

Sairam pashikanti C programming language
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

Sairam pashikanti C programming language
Fig: Converting a lowercase character into an uppercase character


Comments

Popular posts from this blog

Comments In C Programming language

"Introduction to C programming Language"

Program to find Sum and Average of three Numbers