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
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started