Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Accidental Data Scientist

Authors: Amy Affelt

1st Edition

1573877077, 9781573877077

More Books

Students also viewed these Databases questions