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]
2 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]2 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
I need help plzzzzzzzz
Blababa [14]

Answer:

The output is second half of the month, refers to both

4 0
3 years ago
Read 2 more answers
WordArt styles allow you to add ____.
maria [59]
As for this problem, the most probable and the most likely answer to this would be it depends on the person or the user of it since there aren't any options presented with the problem.

WordArt is there to be of use during presentations, during discussions, and other things. On the other hand, as the technological advancement takes leaps and bounds going forward, this utility seems to be underused and isn't expected to give a more impact to the reader or to the recipient of such document that contains it. This is typically used for people that aren't too familiar yet, as to how to utilize other programs to enhance their documents and files.
3 0
3 years ago
To add a hyperlink to your presentation, select the text, choose Hyperlink from the Insert menu, and then
Elan Coil [88]

Answer:

I guessed D, taking it right now, sorry if it's wrong

Explanation:

6 0
2 years ago
Which of the following rules should be used to keep the appropriate distance between your vehicle and the vehicle in front of yo
S_A_V [24]
I would say two car length rule. I am not sure what the official license rule is or if it has been changed, but originally the rule was 3 seconds usually depending on how fast the car is going. The faster you are going, the longer it takes to stop. So two-car length rule would probably be the best choice. Definitely not A.
8 0
3 years ago
Read 2 more answers
The National Vulnerability Database (NVD) is responsible for actively performing vulnerability testing for every company's softw
V125BC [204]

Answer:

False

Explanation:

The answer to this question is false. This is because the NVD doesn't perform such tests on their own. Instead they they rely on third-party vendors, software researchers, etc to get such reports and do the assignment of CVSS scores for softwares

The National Vulnerability Database (NVD) is the United State governments leading resource for software vulnerability

8 0
2 years ago
Other questions:
  • Assume that the population of Mexico is 114 million and that the population increases 1.01 percent annually. Assume that the pop
    9·1 answer
  • General equation: y = (89 / 27) - z * x + a / (a % 2) (recall: a is an integer; the 89 and 27 constants in the equation should b
    14·1 answer
  • Which of the following are characteristics of a cell
    12·1 answer
  • Exampels of semantic tags ?​
    7·1 answer
  • Entering the search criteria "B?" would yield which of the following results?
    6·1 answer
  • When referring to hard drives, access time is measured in
    11·1 answer
  • Predict the output
    7·1 answer
  • I need the answers. i don’t get this
    11·1 answer
  • 1 point
    13·1 answer
  • Explain any two types of board band connection​
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!