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
I need help, who is a great phone pin lock screen cracker?
svlad2 [7]

Answer:

738159

now it's depend on you.

4 0
2 years ago
A user can set the security and privacy settings on what is displayed in the message bar from the ________ within the options me
djverab [1.8K]
Depends on the Operating System
6 0
3 years ago
If wire rope guard rails are used what must also be done?
zzz [600]
A Deceleration device.
A rope, wire rope, or strap with connectors at each end for connecting the 5 point body harness to a lifeline, or anchorage.

Look under OSHA Flashcards on Quizlet and..
OSHA: Fall Protection in Construction, Subpart M and just past that area in the document.

This is from that document on page 13 and 14:  
Fall Restraint Systems:  While fall restraint systems are not mentioned in Subpart M, OSHA recognizes a fall restraint system as a means of prevention. The system, if properly used, tethers a worker in a manner that will not allow a fall of any distance. This system is comprised of a body belt or body harness, an anchorage, connectors, and other necessary equipment. Other components typically include Photo: Skip Pennington OCCUPATIONAL SAFETY AND HEALTH ADMINISTRATION 1 4 a lanyard, a lifeline, and other devices. For a restraint system to work, the anchorage must be strong enough to prevent the worker from moving past the point where the system is fully extended, including an appropriate safety factor. *In a November 2, 1995 interpretation letter to Mr. Dennis Gilmore, OSHA suggested that, at a minimum, a fall restraint system must have the capacity to withstand at least 3,000 pounds or twice the maximum expected force that is needed to restrain the person from exposure to the fall hazard. In determining this force, consideration should be given to site-specific factors such as the force generated by a person (including his/her tools, equipment, and materials) walking, slipping, tripping, leaning, or sliding along the work surface.

8 0
3 years ago
Do all light bulbs server a practical purpose?
Greeley [361]

Answer:

A light bulb produces light from electricity

6 0
3 years ago
Why is it important to record audio of silence in the area in which you are filming?
Serhud [2]

Answer:

To make sure that there is no other outside/excess noise while you are filming your actual film

Hoped this helped !

Cheers, Z

3 0
3 years ago
Read 2 more answers
Other questions:
  • Which mistakes are NOT highlighted by the spell checker in a word-processing document?
    15·2 answers
  • Specifically describe the design process for an Android phone application.
    12·1 answer
  • You start up your laptop while getting a coffee across the room. You hear the usual chimes and doinks as it starts up. When you
    14·2 answers
  • When computing the cost of the basket of goods and services purchased by a typical consumer, which of the following changes from
    11·1 answer
  • Write a program that inputs a time from the console. The time should be in the format "HH:MM AM" or "HH:MM PM". Hours may be one
    6·1 answer
  • Using Phyton
    9·1 answer
  • Define a function compute gas volume that returns the volume of a gas given parameters pressure, temperature, and moles. Use the
    7·2 answers
  • PLZZZZZZZZZZZZZZZ HELP ME OUT!!!!! I SICK AND TIRED OF PEOPLE SKIPING MYQUESTION WHICH IS DUE TODAY!!!!
    14·1 answer
  • What type casting mechanism should be used if you want to safely change (cast) a pointer type for pointing to a different object
    15·1 answer
  • One of the most notable impacts of IT on business is improved
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!