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
What are two software tools for bank account reconciliation?
AysviL [449]

Answer: cashbook and erp system

Explanation:

8 0
3 years ago
Read 2 more answers
A.
FrozenT [24]

Answer:

b. the action is not allowed.

Explanation:

Traffic signs are established rules and regulations designed to direct and guide commuters and other road users.

A red circle and diagonal slash on a sign simply means that the action is not allowed.

A hortatory technique is focused on encouraging, exhorting and urging people to do that which is right, acceptable and worthy of emulation by others.

For example, commuters and road users are being urged not to litter the highway with thrash, waste, or dirt, in order to protect the planet from environmental degradation and pollution. This would help in conserving and mitigating risks posing as a threat to our dear planet and habitat.

Hence, a hortatory technique in policy implementation and enactment is primarily aimed at appealing to the sense and conscience of individuals, to engage in socially responsible acts.

7 0
3 years ago
To prevent rust from forming, a light coating of_____should be applied to all machined surfaces
Fantom [35]
What is that I never heard of that before
4 0
3 years ago
Everfi module 7 answers
Nat2105 [25]
What is the question?
7 0
2 years ago
A blue line, called a ____ line, that appears when you are dragging a GUI object on a Windows Form object indicates that the obj
ser-zykov [4K]

Answer:

snap

Explanation:

The line which appears when we are dragging an object of GUI on a object of  windows Form indicates that the object that is being dragged is aligned horizontally with the object which is connected by the blue line is called a snap line.

Hence we conclude that the answer to this question is snap line.

3 0
3 years ago
Other questions:
  • If you know the unit prices of two different brands of an item you are better able to
    8·1 answer
  • PLEASE HELP ASAP!!!
    8·1 answer
  • When you are working in Performance Monitor, in the "Add Counters" dialog box, and need more information about a particular coun
    8·1 answer
  • anyone got a class named computer literacy? or sum similar to using Microsoft programs? i need a lotttt of help, im 3 units behi
    12·2 answers
  • Hurry please i need this ASAP<br><br>What might be some advantages to keeping CSS and HTML separate?
    8·1 answer
  • A student can improve performance by decreasing
    14·1 answer
  • What is the reason for taking care of design a good computer human interface ​
    9·2 answers
  • Explain the steps in starting the MS Access from the Start Menu.​
    9·1 answer
  • Your connection to this site is not secure how to fix.
    15·1 answer
  • Question 2 of 10
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!