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
printArray is a function that has two parameters. The first parameter is an array of element type int and the second is an int,
Illusion [34]

Answer:

printArray(inventory, n);

Explanation:

The question doesn't specify in which language this has to be done, here's a generic call then... so if it's aimed at a specific language, some minor adjustments might be needed to respect the proper syntax/structure of that specific language.

Given:

printArray: function name, using 2 parameters.

inventory: array of ints

n : integer, number of items in array inventory

The call to the function would be:

printArray(inventory, n);

7 0
3 years ago
I need help ASAP Please! :)
amid [387]
Your parents,your school,google,your social media accounts
3 0
3 years ago
Step 1: Configure the initial settings on R1. Note: If you have difficulty remembering the commands, refer to the content for th
Andru [333]

Answer:

The configuration of the R1 is as follows

Explanation:

Router>enable

Router#show running-config

Router#show startup-config

Router#configure terminal

Router(config)#hostname R1

R1(config)#line console 0

R1(config-line)#password letmein

R1(config-line)#login

R1(config-line)#exit

R1(config)#enable password cisco

R1(config)#enable secret itsasecret

R1(config)#service password-encryption

R1(config)#banner motd #Unauthorized access is strictly prohibited#

R1(config)#end

R1#exit

R1>enable

R1#copy running-config startup-config

R1#show flash

R1#copy startup-config flash

3 0
3 years ago
What piece of equipment is NOT a tool that would be considered appropriate equipment for on-site visits? a. multimeter b. flashl
Anton [14]

The oscilloscope is NOT a tool that would be considered appropriate equipment for on-site visits. The oscilloscope is an electronic test instrument used to observe observation constantly varying signals. This instruments is used in laboratories, and not on-site visits.

All other instruments are moveable and can be used on-site.


3 0
3 years ago
Is the app scener safe? its a chrome webstore app on computer.​
Sophie [7]

Answer:

Maybe

Explanation:

If you are unsure if a website is safe look for signs. If its asking you to allow advertisement then no. I suggest you download a VPN before going to the website just to be safe

5 0
3 years ago
Other questions:
  • Changeover means that ____. (select all that apply)
    7·2 answers
  • Type the correct answer in the box. Spell all words correctly.
    13·1 answer
  • How does computer network work in a paragraph
    12·1 answer
  • Can your digital footprint be destroyed or does it remain active on the internet forever
    5·1 answer
  • If you do not want to keep a change made by the autocorrect feature, you can click the ____ button on the auto correction option
    12·1 answer
  • Allie is working on the development of a web browser and wants to make sure that the browser correctly implements the Hypertext
    7·1 answer
  • A TCP ________ segment is a request to the other transport process to close a connection. ACK FIN SYN CLS
    15·1 answer
  • Why is it uncommon for users to perform searches directly in database tables?
    15·1 answer
  • Why are default parameters useful? *This is JavaScript*
    7·1 answer
  • Which of the following statements best illustrates how value was created for eggs? when a farmer sells a chicken who is no longe
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!