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
A linear gradient can be positioned from left to right, top to bottom, or on any angle?
Harman [31]

from left to right because it is used more in expressions

3 0
3 years ago
Anil needs to show the overlap of people who live in a certain neighborhood in his city and who support a specific political can
pantera1 [17]

Since Anil needs to show the overlap of people who live in a certain neighborhood in his city that supports a specific political candidate, the type of conceptual diagram which he should use is a: B: Venn diagram.

<h3>What is a Venn diagram?</h3>

A Venn diagram can be defined as a circular graphical (visual) tool that is typically used for representing, logically comparing and contrasting two (2) or more finite sets of data such as objects, students, events, voters, concepts, people, etc.

In this context, we can reasonably infer and logically deduce that a Venn diagram is a type of conceptual diagram which can be used by Anil in illustrating the overlap of people who are living in a certain neighborhood in his city and supports a specific political candidate in an election.

Read more on Venn diagram here: brainly.com/question/24581814

#SPJ1

8 0
1 year ago
Which of the following is not an Operating System? (1 point)Windows
kobusy [5.1K]
The answers of the following are:

1.  The answer is Linux. It is not an Operating System.
2. Windows XP 2000 and Windows XP Home Edition have the same interface design. 
3. Linux is the operating systems which is considered to be open source.
4. Mac OS is an operating system which is considered to be the most popular with graphic and multimedia designers
5. The software programis the number and variety of programs available for a particular operating system.
4 0
4 years ago
Your boss calls you from his home to use the VPN connection you configured for him
prisoha [69]

Its not c or b. I think it's a. Im not sure tho..

7 0
3 years ago
The Matlab Script should:1. Clear the command window2. Clear the workspaceQuestion 1: Why do we clear the command window and wor
finlep [7]

Answer:

This is done for the simple reason of having more space to work on

Explanation:

This is done for the simple reason of having more space to work on. By clearing the command window and workspace you provide yourself with sufficient space to create new commands without the clutter of the previous commands. This also prevents your focus from shifting towards old commands and allows you to simply focus on the commands you are currently working on. This does not clear all variables from the script, it only clears the current screen but the previous commands can still be accessed by using the up-arrow key

5 0
3 years ago
Other questions:
  • Why should you limit what information is in your digital footprint?
    12·1 answer
  • You are asked to optimize a cache design for the given references. Th ere are three direct-mapped cache designs possible, all wi
    7·1 answer
  • By default, PowerPoint ends a slide show with a black slide. <br> a. True<br> b. False
    5·2 answers
  • The domain in an email message tells you the
    8·1 answer
  • Generally considered to be the most important information security policies, what item below defines the actions a user may perf
    11·1 answer
  • How do you respond to an email?
    6·1 answer
  • What is the difference between spyware and adware?
    8·2 answers
  • A company database needs to store information about employees (identified by ssn, with salary and phone as attributes), departme
    7·1 answer
  • ANYONE WANNA FRIEND ME ON DISCORD ゴRose joestarゴ#2088
    9·1 answer
  • What is a distinguishing feature of 5G mm Wave?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!