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
Mention how to install antivirus software in your computer, either by following the instructions given on installation CDs or we
Tema [17]

Answer:

ionow please help me

Explanation:

5 0
3 years ago
can anyone sub to my youttube channel pls, its called Yakobu, and Im trying to reach 100 subs by the end of the month :)
allsm [11]

Answer:

Sure

Explanation:

3 0
3 years ago
You have just taken over management of a server on which the previous server administrator has set up several server components,
Arisa [49]

Answer:

d. Ensure file caching and flushing are enabled for all disk drives.

Explanation:

When the disk reading and writing is delayed and the server performance is also slow after taking over management of a server.Previously the server has several server components.So to increase the performance we should ensure caching of the file and make sure that the flushing is enabled for all disk drives.Hence the answer to this question is option d.

8 0
3 years ago
PLS HELP
kvasek [131]

Answer:

informative, discrimiitive,critical thats the order

4 0
3 years ago
Which type of partitioning is performed onRelation-X?
goldenfox [79]

Answer: B) Vertical Partitioning

Explanation:

As, vertical partitioning is performed on Relation X, it is used for dividing the relation X vertically in columns and it involves creation of tables and columns. They also use some additional tables to store left out columns. We cannot partition the column without perform any modification of value of the column. It only relies on keeping the particular attributes of relation X.

7 0
3 years ago
Other questions:
  • Using a loop, write a program that reads in exactly five integers and outputs the sum.
    11·1 answer
  • Peter has recently bought a media player and a digital camera he wants to buy a memory card and then use devices which memory do
    11·2 answers
  • JavaBeans are?A special Java classfileServletsAppletsA Special form of JSPNone of Given
    8·1 answer
  • You change a document that is saved on your computer by cutting text from the document what happens to the text when you preform
    5·1 answer
  • Who is hurt by piracy
    10·1 answer
  • Which custom configuration is most likely to include a raid array?
    14·1 answer
  • All of the following are organization habits except:
    10·1 answer
  • A solid understanding of __________ is the foundation of verbal communication
    7·1 answer
  • Write a public static method named evens that takes in 1 argument int a, and returns a String containing all positive even numbe
    8·1 answer
  • Examples of 15 viruses in computer
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!