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
When an Ethernet NIC has been configured by the OS to use half-duplex, the transmit pair of the twisted-pair cable usestransmiss
zzz [600]

Answer:

C

Explanation:

When an Ethernet NIC has been configured by the OS to use half-duplex, the transmit pair of the cable uses SIMPLEX transmissions, the receive pair in the SIMPLEX transmissions, and the twisted pair cable uses HALF-DUPLEX transmissions.

Cheers

7 0
3 years ago
The ? contains software routines that developers use to create a consistent computer environment
Luba_88 [7]

The toolbox contains software routines that developers use to create a consistent computer environment.

3 0
2 years ago
Read 2 more answers
It's possible to __________ out of a loop if the user has entered an incorrect value that would cause an error or a problem with
Stella [2.4K]

Answer:

The answer is Break

<u>Explanation:</u>

When break statement is occurred then, it immediately exits from the loop and executed the statement after the loop without raising any kind of error.

<u>The situation after entering of a value by a user </u>

  • If the user entered incorrect value then it will exit from the loop.
  • If the user entered correct input value, then it will run the loop for the further values.

4 0
2 years ago
Um?<br><br> i went to check my questions and i found this-
asambeis [7]

Answer:

just go ahead and refresh the page

Explanation:

5 0
2 years ago
Which step do you think is most useful from big data life cycle.why?
12345 [234]

Explanation:

Business xase evaluation is most useful because (BCA) provides a best-value analysis that considers not only cost but other quantifiable and non-quantifiable factors supporting an investment decision. This can include but is not limited to, performance, producibility, reliability, maintainability, and supportability enhancements.

Mark me brainliest

7 0
1 year ago
Other questions:
  • Why are computer programs so much longer now than they were in the late 1980?
    8·1 answer
  • Which of the following best describes a group?
    13·1 answer
  • g Define memory hierarchy. A. The rate at which information can be transferred from one place to another. B. Ordering storage sy
    8·1 answer
  • Effective display designs must provide all the necessary data in the proper sequence to carry out the task. Identify a recent pe
    12·1 answer
  • Which of the following prefixes would be best to use when measuring your own mass?
    15·1 answer
  • Watson Studio is the IBM premier integrated development environment for data science and artificial intelligence practitioners.
    5·1 answer
  • You upgrade a graphics workstation with a HyperThreading-enabled CPU core. You expect the programs on the desktop to run much fa
    12·1 answer
  • 1. A bank customer invested $24 in a bank with 5 percent simple interest per year, write a program the construct a table showing
    11·1 answer
  • Unit 2: Lesson 6 - Coding Activity 1
    10·1 answer
  • When constructing policies regarding data _______________, it is important that these policies offer particular guidance on sepa
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!