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
Ostrovityanka [42]
3 years ago
6

Write a calculator program using a switch statement that: a) Prompts the user to enter two numbers b) Prompts the user to select

between the four arithmetic operations using a choice from 1-4; for example, prompt the user with: "Choose 1) for add, 2) for subtract, 3) for multiply or 4) for divide)" c) Calculates the result of performing the selected operation on the numbers; and d) Displays the answer on the screen. (15 pts)
Computers and Technology
1 answer:
ollegr [7]3 years ago
6 0

Answer:

Following are the code in C language

#include <stdio.h> // header file

int main() // main method

{

   float f1; // variable declarartion

   float x,y; //variable declarartion

   int option;//variable declarations

   printf("Enter Two numbers:");

   scanf("%f%f",&x,&y);// input two number

   printf("Choose : 1: For add 2: For Subtract 3: for multiply 4: for divide");

   scanf("%d",&option); //read the choice

   switch(option)

   {

       case 1: //  for addition

   printf("%4f",x+y);

          break;

          case 2:// for subtraction

   printf("%4f",x-y);

          break;

          case 3: //for multiply

      printf("%4f",x*y);

          break;

      case 4: // for division

      f1=x/y;

   printf("%4f",f1);

          break;

      default: ////for invalid choice

          printf("Invalid choice") ;

  }

return 0;

}

Explanation:

In this program we taking a two input from user of float types after taking input,the switch statement is used case 1 for addition,case 2 for subtraction case 3 for multiplication,case 4 for division and default for invalid choice .

Output

Enter Two numbers:2.5

2.5

Choose : 1: For add 2: For Subtract 3: for multiply 4: for divide:4

1.000000

You might be interested in
Now let's create a memo. The memo should include all parts of a memo, and these parts should appear in the correct order. In you
netineya [11]

Answer:

MEMORANDUM

TO: Stacy Shoe, Allen Sock, and Emma Johnson.

FROM: Department of Information

DATE: 20th of December, 2019

SUBJECT: Computer Operations

The following is an illustration of how to start a computer and how to open an existing word processing document. For clarity and ease of understanding, this will be divided into two subheadings. All questions should be directed to the department of information.

START A COMPUTER

Step 1: Press the start button on the CPU tower.

Step 2: Wait while the computer boots. When the computer has finished booting, it will show a dialogue box that will ask for a user name and password.

Step 3: Enter your user name and password, then click

"OK."

Step 4: Your computer is now ready to use.

OPENING A WORD PROCESSING DOCUMENT

To open any word processing documents, you can use any of the options below.

1. Double-click file

In some cases, you can double-click a file to open it in Microsoft Word. However, the file will only open in Microsoft Word if that file type is associated with Microsoft Word. Word documents, like .doc and .docx files, are associated with Microsoft Word by default. However, web page files, text, and rich text format files are often not associated with Word by default, so double-clicking on these files may open in another program.

2. Right-click file and select program

For any file, you can choose the program to open a file with, including Microsoft Word.

Step 1: Right-click the file you want to open.

Step 2: In the pop-up menu, select the Open with option.

Step 3: If available, choose the Microsoft Word program option in the Open with menu. If Microsoft Word is not listed, select the Choose other app or Choose default program option, depending on the

Step 4: In the window that opens, find Microsoft Word in the program list and select that option. Microsoft Word should open and the file opened within Word.

3. Open within Microsoft Word

Follow the steps below to open a file from within Microsoft Word.

Step 1: Open the Microsoft Word program.

Step 2: Click the File tab on the Ribbon and click the Open option.

Step 3: If the Open window does not appear, click the Browse option to open that window.

Step 4: In the Open window, find and select the file you want to open in Microsoft Word. You may need to click the drop-down list next to the File name text field to change the file type to that of the file you want to select and open.

Step 5: Click the Open button at the bottom right of the Open window.

As stated above, all questions are to be directed to the department of information.

Thanks.

Explanation:

5 0
3 years ago
In Tynker, it is not possible to create a/an __________.
xz_007 [3.2K]

Answer:

yes

Explanation:

7 0
2 years ago
Read 2 more answers
Please helpppppppppppppppppp please I’m stuck!
Vinvika [58]

do u know thw muffin man

3 0
3 years ago
The primary stream fed by tributaries within a dendritic drainage network is termed a ________ stream
a_sh-v [17]
<span>TRUNK. In a dendritic system, there are many smaller rivers or streams (the "twigs" of the tree), which are then merged into the tributaries of the main river (the branches and the trunk of the tree, respectively). They tend to develop in V-shaped valleys</span>
6 0
3 years ago
On many advanced routers and switches, you can implement QoS through bandwidth management, such as __________, where you control
Mila [183]

Answer:

c. traffic shaping

Explanation:

A traffic shaping system is one that allows to adapt the incoming data traffic that comes from some node of the network giving it a special treatment called conformation of accepted traffic and thus allowing the frames to be forwarded through the network of data under traffic rules without having gone through some traffic shaping method, this can be detected as non-conforming traffic at the edge of access to the discarded metropolitan network.

Traffic shaping is a mechanism that alters the traffic characteristics of the cell flow of a connection to achieve better network efficiency while maintaining QoS objectives or in order to ensure that the cell flow conforms to traffic parameters according to the leaky bucket algorithm configuration of the traffic contract. Traffic shaping can be used in ATM, for example, to reduce peak speed, limit the length of the burst by means of adequate spacing of cells over time. The use and location of this function is network specific.

5 0
3 years ago
Other questions:
  • By issuing concert tickets on the blockchain, fans can verify transfer of ownership from one digital wallet to another, rather t
    14·1 answer
  • Each of the walls of a room with square dimensions has been built with two pieces of sheetrock, a smaller one and a larger one.
    11·1 answer
  • Help me out with this .....
    10·1 answer
  • What is a text designed for editing and authoring code is<br> A code editor <br> B
    9·1 answer
  • Given a int variable named callsReceived and another int variable named operatorsOnCall write the necessary code to read values
    13·1 answer
  • GMI = $4,666.67 Total Monthly Deductions $1,131.00 What is the Net Monthly Income (GMI - Total Monthly Deductions) =
    9·1 answer
  • What do macOS and Windows use to prevent us from accidentally deleting files?
    15·1 answer
  • 20 POINTS! Which music making software is better? Ableton Live or Logic Pro? Name the advantages and disadvantages of each one!
    7·2 answers
  • SmartArt is a Microsoft Office tool for creating what?
    11·2 answers
  • Define the term loop rule.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!