In this tutorial you will learn about the C Program to Convert Character to Lowercase and its application with practical example.
C Program to Convert Character to Lowercase
In this tutorial, we will learn to create a C program that will Convert Character to Lowercase in C programming.
Prerequisites
Before starting with this tutorial, we assume that you are the best aware of the following C programming topics:
- Operators in C Programming.
- Basic Input and Output function in C Programming.
- Basic C programming.
- Conditional Statements in C programming.
What is a character?
The character is a single entity in the English language or in any word. These characters can be any alphabets in lower case or upper case.
The lower case means the small letters. And the upper case means the capital letters of the English language.
For Example:-
In the word “W3Adda”, there are six characters, they are as follows
- ‘W’
- ‘3’
- ‘A’
- ‘d’
- ‘d’
- ‘a’
Here,
‘W’ is a character in the Upper case.
‘3’ is a digit.
‘A’ is a character in the upper case.
‘d’ is a character in the lowercase.
‘d’ is a character in the lower case.
‘a’ is a character in the lowercase.
Algorithm:-
1 2 3 4 5 6 7 8 9 10 11 |
1. Declaring the variables for the program. 2. Taking the input character from the user. 3. Passing that variable to conditional statements. 4. Using those conditions to Convert Character to Lowercase. 5. Printing the resultant character. 6. End The Program. |
Program to Convert Character to Lowercase
First, we will take the input character from the user. Then will pass that character in the conditional statements to check and convert it into the character to lower case.
With the help of this program, we can convert that character to lower case.
Program Code:-
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
/* ** C Program to Convert Character to Lowercase ** */ #include <stdio.h> #include<ctype.h> int main() { //Declaring the required variables for the program. char Chr; //taking the input character from the user. printf("\n Please Enter any alphabet\n"); scanf(" %c", &Chr); //Checking that aplhabet and converting it into lower case if (isalpha(Chr) ) { if (Chr>=65 && Chr<=90) { Chr = Chr + 32; //printing the coverted output by the program. printf ("\n Lowercase of Entered character is %c", Chr); } else { //printing the coverted output by the program. printf("\n You Already Entered Lowercase Character"); } } else { //printing the coverted output by the program. printf("\n Entered character is Not an Alphabet"); } } |
Output:-
In the above program, we have first initialized the required variable.
- Chr = it will hold the character value for the input.
Input character from the user.
Checking the given character is an alphabet and covert it into a lower case alphabet.
Printing lowercase characters.