Question: C++ Program: The following program reads one character from the keyboard and will display the character in uppercase if it is lowercase and does the

C++ Program: The following program reads one character from the keyboard and will display the character in uppercase if it is lowercase and does the opposite when the character is in uppercase. If the character is a digit, it displays a message with the digit.

// This program reads one character from the keyboard and will // convert it to uppercase. If it is lowercase, convert it to uppercase.

// If it is a digit display a message with the digit.

#include #include using namespace std;

int main( ) { char c;

cout << "Enter a character "; cin >> c;

if(isalpha(c)) { //check to see if it is a letter of alphabet if( isupper(c) ) //check to see if it is uppercase { cout << "Your character " << c << " is in uppercase."; c = tolower(c); cout << "Its lowercase case is " << c << endl; } else {

cout << "Your character " << c << " is in lowercase."; c = toupper(c); cout << "Its uppercase is " << c << endl; } } else { cout << "Your character " << c << " is a digit. "; }

return 0; }

Modify the above program such that if one of the whitespaces is entered, it displays a message and tells what the character was.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!