In this tutorial you will learn about the C Program to Convert Character to Uppercase and its application with practical example.
C Program to Convert Character to Uppercase
In this tutorial, we will learn to create a C program that will Convert Character to Uppercase 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
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 Uppercase. 5. Printing the resultant character. 6. End The Program. |
Program to Convert Character to Uppercase
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 Upper case.
With the help of this program, we can convert that character to upper 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 |
/* ** C Program to Convert Character to Uppercase ** */ #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 upper case if (isalpha(Chr) ) { Chr = toupper(Chr); //printing the coverted output by the program. printf ("\n Uppercase of Entered character is %c", Chr); } else { //printing the coverted output by the program. printf("\n Please Enter Valid 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 an upper case alphabet.
Printing lowercase characters.