Program to convert lowercase character to uppercase and vice versa. (Level - Medium)

Program # 14: Program to convert lowercase character to uppercase and vice versa 

Program to convert lowercase character to uppercase and vice versa. (Level - Medium)

#include <iostream>
using namespace std;


int main()
{
char ch;

cout<<"Please input a valid character (Alphabet): ";
cin>>ch;

//check for valid alphabet
if((ch>='A' && ch<='Z') || (ch>='a' && ch<='z'))
{
//check case and convert into opposite case
if(ch>='A' && ch<='Z')
ch=ch+32;
else if(ch>='a' && ch<='z')
ch=ch-32;
else
; //none

cout<<"converted character is: "<<ch<<endl;

}
else
{
cout<<"Entered character is not a valid alphabet!!!"<<endl;
}

return 0;
}

Post a Comment

0 Comments