1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
natta225 [31]
3 years ago
5

Give an example of an if/else statment and a case statment that are equivalent. Your example should contain at least three choic

es.
Computers and Technology
1 answer:
zimovet [89]3 years ago
4 0

Answer:

The if - else and equivalent switch case statements in c++ language are given below.

if ( ch == 1 )

       cout << " sum is " << x + y << endl;

   else if ( ch == 2 )

       cout << " difference is " << x - y << endl;

   else if ( ch == 3 )

   {

       cout << " Quitting " << endl;

       exit;

   }

switch( ch )

   {

       case 1 :    cout << " Sum is " << x + y << endl;

                   break;

       case 2 :    cout << " Difference is " << x - y << endl;

                   break;

       case 3 :    cout << " Quitting " << endl;

                   break;

   }      

Explanation:

The above statements use three variables which are declared and initialized as shown.

int x = 10;

    int y = 25;

    int ch;

The above statements execute for of addition, subtraction or to quit the program.

cout << " 1. Addition " << endl;

    cout << " 2. Subtraction. " << endl;

    cout << " 3. Quit " << endl;

    cout << " Enter your choice " << endl;

The variable ch holds the numerical option entered by the user.

    cin >> ch;

For if - else statements, the if statement is executed based on the value of variable ch entered by the user. After execution, the compiler goes out of the statements automatically.

Following the if – else, if any statement is present, it will be executed.

For switch case, every case ends with break keyword. After the required case is executed based on the value of variable ch entered by the user, the break statement is executed which causes the switch case to terminate the control goes out of the statements.

Following the switch case, if any statement is present, it will be executed.

You might be interested in
What do mobile platforms utilize to stream voice, IP telephony, mobile internet access, video calling, gaming services, cloud co
Anuta_ua [19.1K]

Answer:

4G/5G.

Explanation:

The broadband cellular network technology that mobile platforms utilize to stream voice, IP telephony, mobile internet access, video calling, gaming services, cloud computing, high-definition mobile TV, and mobile 3-D TV is 4G/5G.

4G technology refers to the fourth generation broadband cellular network technology that is typically used for cellular communications on mobile phones and it is considered to have an internet speed that is ten times faster than what is obtainable on the third generation (3G) broadband technology.

Similarly, 5G is the fifth generation broadband cellular network technology that succeeded 4G and it offers higher quality in terms of performance, reliability, availability and efficiency.

As a result of the speed and high quality specifications of the 4G/5G broadband cellular network technology, they are widely used for various communications systems.

5 0
3 years ago
What line has the bug?
gtnhenbr [62]

Answer:

14

Explanation:

there is never { to start the code

7 0
2 years ago
Read 2 more answers
6. What are the arguments, pros and cons, for Python's use of indentation to specify compound statements in control statements
Nat2105 [25]

Answer:

beinggreat78~here~to~help.

In some cases, one con is that it can be hard to keep track of your identation when coding long lines or blocks. The pro is that you may need to learn, which is not a bad thing. Learning is good.

5 0
3 years ago
When multiple frames arrive at the same location at the same time resulting in a garbled signal is called what?
Inessa05 [86]

Answer:

A

Explanation:

because there are multiple frames

4 0
3 years ago
How do you customize Track Changes in a text document?
lora16 [44]

If its on document u go to text u highlight ur text and then you go upload track changes text on computer or phone or any divice and then you insert the text u wrote to the app and then if u cant find the app look for text changing colors and then copy and past ur work to the app and add the colors to it.

8 0
4 years ago
Other questions:
  • The ______ is the information center that drivers need to refer to when they're NOT scanning the road.
    7·1 answer
  • Name and summarize the four levels of administration necessary to keep human services organization operating smoothly
    9·2 answers
  • Which of the following functions sends the the GPA entered by the user to the calling function? A. def get_gpa(): gpa = float(in
    8·1 answer
  • In the single-site processing, single-site data (SPSD) scenario, all processing must be done on the end user's side of the syste
    10·2 answers
  • ____ allows you to control how objects enter, move on and exit slides
    13·1 answer
  • The requirement, "The system shall receive information quickly," is an example of a functional requirement.
    15·1 answer
  • ____________ define the allowable interactions between subjects and objects. credentials responsibilities procedures access cont
    15·2 answers
  • What is an I-94?
    14·1 answer
  • Jennifer has written a short story for children. What should be her last step before she submits the story for publication?
    6·1 answer
  • Who are all the fnaf characters?
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!