Here is source code of the C++ program which changes the case of the given alphabetical character. The C++ program is successfully compiled and run on a Linux system. The program output is also shown below.
* C++ Program to Change the Case of given Alphabetical Character
using namespace std;
cout << "Enter the character : ";
cin >> c;
cout << c << " is not an alphabetical character." << endl;
if (c >= 'a' && c <= 'z')
c = c - 'a' + 'A';
case_val = 1;
else if (c >= 'A' || c <= 'Z')
c = c + 'a' - 'A';
case_val = 0;
cout << c << " is the " << ( (case_val == 1) ? "upper" : "lower" )
<< " case of given character " << endl;
$ g++ main.cpp $ ./a.out Enter the character : a A is the upper case of given character $ ./a.out Enter the character : A a is the lower case of given characte
Sanfoundry Global Education & Learning Series – 1000 C++ Programs.
If you liked this C++ Program, kindly share, recommend or like below!