Read a character and convert it into uppercase if it is in lowercase or vice-versa - C

Q. WAP to read a character from keyboard and convert it into uppercase if it is in lowercase or vice-versa.
#BIT_FirstSem_2015_11No_8Marks_Solution
==>Code goes like this:

#include<stdio.h>
int main()
{
    char ch;
    printf("Enter a character: ");
    scanf("%c",&ch);
    if(ch>64 && ch<91)
    printf("%c",ch+32);
    else
    printf("%c",ch-32);
    return 0;

}

Output:
 







If you are using Turbo C++ IDE, then use conio.h in link section after stdio.h
and use getch(); to hold the output screen, just before the end of main function.
If you have any confusion regarding the program, please, comment below.
Happy Coding !
Thank you
Share on Google Plus

About Nepali Xoro

Interested in Information Technology, Spreading Knowledge for Nepalease IT Students."Loves Traveling", Listen Music and Surfing web.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment