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
Which line of code will use the overloaded multiplication operation?
maks197457 [2]

Answer:

def __mul__(self, b):

Explanation:

correct edge 2021

4 0
3 years ago
You give an object a more meaningful name by setting the object’s _________________ property.
viva [34]

Answer:

The correct answer to this question is "Name".

Explanation:

In the programming language, the object is a part of the object-oriented programming language (oops).In all (oops) programming language we use class and object. where class is a collection of data member and member function, and object is a real-world entity. An Object is an instance of a Class. When a class is created, no memory is assigned but when we create the object of the class then memory is allocated.

In this question except option (d), all options are wrong.

7 0
3 years ago
True or false, alcohol tends to produce passive behavior in most people
goldenfox [79]
The answer to your Question is false 

7 0
3 years ago
Read 2 more answers
An ip address in the address range 169.254.x.y, used by a computer when it cannot successfully lease an ip address from a dhcp s
Georgia [21]
Yes that is the correct answer


5 0
3 years ago
Read the following examples, and decide whether each example describes a relational database or a flat
bezimeni [28]

Answer: flat file, relational database, relational database, relational database

Explanation:

Edge

7 0
3 years ago
Read 2 more answers
Other questions:
  • Technician A says one disadvantage of fiber optic cables is that they are more expensive and very heavy. Technician B says one d
    6·1 answer
  • Employees at a store are paid daily wages according to the following rules.
    6·1 answer
  • IF YOU ARE COMPUTER MASTER TELL ME WHICH SOFTWARE IS USED IN CALLIGRAPHY
    6·2 answers
  • David has created a lot of styles and now his Quick Style Gallery contains styles he no longer uses.
    10·1 answer
  • The ____________________ utility uses the Burrows-Wheeler Block Sorting Huffman Coding algorithm when compressing files.a) bzip2
    11·1 answer
  • How to check if serial interface is dte ot DCE?
    13·1 answer
  • Which of the columns (A) to (I) in the truth table below is correct for the expression
    13·2 answers
  • Fill in the sentences with the correct terms.
    7·2 answers
  • Which step do you think is most useful from big data life cycle.why?
    9·1 answer
  • In a ________ system configuration, separate information systems are designed and managed by each foreign unit.
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!