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
A major problem with alcohol adverstising is that
Pavel [41]

Answer:

A chronic disease characterized by uncontrolled drinking and preoccupation with alcohol.

Alcoholism is the inability to control drinking due to both a physical and emotional dependence on alcohol.

Symptoms include a strong need or urge to use alcohol. Those with alcohol use disorder may have problems controlling their drinking, continue to use alcohol even when it causes problems, or have withdrawal symptoms when they rapidly decrease or stop drinking.

Treatment involves counseling, such as behavioral therapy, and medications that reduce the desire to drink. Some people need medical detoxification to stop drinking safely. Mutual support groups help people stop drinking, manage relapses and cope with necessary lifestyle changes.

Explanation:

8 0
3 years ago
. What is an APT? What are some practical strategies to protect yourself from an APT?
viva [34]

Answer and Explanation:

Advanced Persistent Threat abbreviated as APT is a type of cyber attack which gives access to the unauthorized user  to enter the network without being detected for a long period.

APTs are generally sponsored by the government agencies of the nation or large firms. For example, one of the ATPs used was Stuxnet in the year 2010 against Iran, in order to put off the nuclear program of Iran.

Some of the practical strategies for protection against APT are:

  • Sound Internal Auditing
  • Strong Password Accessing Policies
  • Stringent policies for accessing any device
  • Introduction and implementation of multi factor authentication
  • Strong IDs and sound honeypot solutions
3 0
3 years ago
Select all the correct answers.
Dvinal [7]

Answer: Avoid forwarding a personal email to others and most likely Avoid forwarding jokes and trivia using email.

8 0
3 years ago
Match the correct features to virtualization and cloud computing.
ololo11 [35]

Answer:

i think i know

Explanation:

8 0
3 years ago
Who are the key players in the internet
Anna007 [38]
Gamers my dude, dank memes are also the internet's finest minds
4 0
3 years ago
Other questions:
  • How to write equal to or greater than in word?
    9·1 answer
  • The _______ valve protects the air pump from reverse-exhaust pressure.
    11·1 answer
  • Damage to which portion of the limbic system results in loss of memory of recent events and difficulty committing anything new t
    13·1 answer
  • Write a program that converts or calculates values. Use the following guidelines to write your program:
    8·1 answer
  • When a crash results in property damages of any amount, the driver must notify:
    10·1 answer
  • Which is a tool that allows you to copy formatting from one place and apply it to other places?
    9·1 answer
  • Which two wildcard masks are required in an extended access list entry that blocks the traffic from network 192.168.20.0/26 to n
    9·1 answer
  • Organizations should communicate with system users throughout the development of the security program, letting them know that ch
    12·1 answer
  • Explain the importance of technology in at least 100 words
    11·1 answer
  • Convert 1/32 GB into MB​
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!