Rewrite program 10.1 Carefully look at the coded IF statements. All the IF statements between lines 13-22 are executed. But if you think about it, some cases are mutually exclusive or otherwise do no apply when other conditions are true. Rewrite the program using ELSE statements and/or nested IF statements. The code should not execute an IF statement that it logically does not need to. However, the runtime results should be the same as the original program. Deliverable is cpp program and either (a flow chart or pseudo c

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter5: Control Structures Ii (repetition)
Section: Chapter Questions
Problem 28PE
icon
Related questions
Question

C++ Program

Rewrite program 10.1

Carefully look at the coded IF statements. All the IF statements between lines 13-22 are executed. But if you think about it, some cases are mutually exclusive or otherwise do no apply when other conditions are true.

Rewrite the program using ELSE statements and/or nested IF statements. The code should not execute an IF statement that it logically does not need to. However, the runtime results should be the same as the original program.

Deliverable is cpp program and either (a flow chart or pseudo code or both).

program 10.1

// This program demonstrates some character-testing functions.
 2
#include <iostream>
 3
#include <cctype>
 4
using namespace std;
 5
 
 6
int main()
 7
{
 8
char input;
 9
 
10
cout << "Enter any character: ";
11
cin.get(input);
12
cout << "The character you entered is: " << input << endl;
13
if (isalpha(input))
14
cout << "That's an alphabetic character.\n";
15
if (isdigit(input))
16
cout << "That's a numeric digit.\n";
17
if (islower(input))
18
cout << "The letter you entered is lowercase.\n";
19
if (isupper(input))
20
cout << "The letter you entered is uppercase.\n";
21
if (isspace(input))
22
cout << "That's a whitespace character.\n";
23
return 0;
24
}
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Mathematical functions
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning