(b)Convert the following C++ code from if-Statement to switch-statement, such that it gives the same output. int x; cin >> x; if (x == 1) cout < "EXCELLENT"; else if ((x == 2) || (x == 3) || (x == 4)) cout << "GOOD"; else cout < "BYE BYE";

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter5: Repetition Statements
Section: Chapter Questions
Problem 3PP: (Physics) A golf ball is dropped from an airplane. The distance, d, the ball falls in t seconds is...
icon
Related questions
Question
100%
(b)Convert the following C++ code from if-Statement to switch-statement, such
that it gives the same output.
int x;
cin >> x;
if (x == 1)
cout < "EXCELLENT";
else if ((x == 2) || (x == 3) || (x == 4))
cout << "GOOD";
else
cout < "BYE BYE";
Transcribed Image Text:(b)Convert the following C++ code from if-Statement to switch-statement, such that it gives the same output. int x; cin >> x; if (x == 1) cout < "EXCELLENT"; else if ((x == 2) || (x == 3) || (x == 4)) cout << "GOOD"; else cout < "BYE BYE";
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Datatypes
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++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr