Write a C program that reads in a lowercase character, converts it to uppercase and then displays the uppercase equivalent

C program that converts lowercase character to its uppercase equivalent and displays it

Explanation
Step 1: Read the lowercase character
Step 2: Convert the lowercase character to its uppercase by using the library function toupper()
Step 3: Display the converted uppercase character

Note:
The function toupper() used in this program is a library function which is generally included in the header file ctype.h and the purpose of this function is to convert the lowercase letter to its uppercase.

#include<stdio.h>
#include<ctype.h>

void main()
{
   char lower, upper;
   lower = getchar();
   upper = toupper(lower);
   putchar(upper);
}

Output:

l
L

You may also like...

3 Responses

  1. bijay pokhrel says:

    #include
    #include
    void main()
    {
    char ch;
    clrscr();
    printf(“Enter a Character”);
    scanf(“%c”,&ch);
    if(ch>=65 && ch<=90)
    ch=ch+32;
    ch=ch-32;
    printf("your changed character =%c",ch);
    getch();
    }

  2. bijay pokhrel says:

    /* WAP to change case of a character*/
    #include
    #include
    void main()
    {
    char ch;
    clrscr();
    printf(

  3. Excoded says:

    lower = getchar();
    This line returns a character you entered and it may not be a lowercase letter. It can be any character you inputted.

Leave a Reply

Your email address will not be published. Required fields are marked *

FREE C Cheatsheet - Speed Up Your C Programming.

FREE C Cheatsheet - Speed Up Your C Programming.

Download a 7-page free cheat sheet for easy and quick access to C Concepts, Snippets, and Syntax.

Thank you! Check you inbox and access your cheat-sheet