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
Tatiana [17]
4 years ago
10

Write a program in c or c++ to perform different arithmeticoperation using switch statement .the program will take two inputinte

gers from the user and then an arithmetic operator from theuser to perform the specific operation the given twointegers?

Computers and Technology
1 answer:
baherus [9]4 years ago
6 0

Answer:

C code :

#include<stdio.h>

int main()

{

int j;

float k,l, x;  //taking float to give the real results.

printf("Enter your two operands: ");  //entering the numbers on which      //the operation to be performed.

scanf("%f %f", &k, &l);

 

printf("\n Now enter the operation you want to do: ");

printf("1 for Addition, 2 for Subtraction, 3 for Multiplication, 4 for Division ");

scanf("%d", &j);  //j takes the input for opearation.

 

switch(j)  

{

 case 1:  

  x=k+l;

  printf("%.2f+%.2f=%.2f",k,l,x);   //we write %.2f to get the result //upto 2 decimal point.

  break;

   

 case 2:

  x=k-l;

  printf("%.2f-%.2f=%.2f",k,l,x);

  break;

 case 3:

  x=k*l;

  printf("%.2f*%.2f=%.2f",k,l,x);

  break;

 case 4:

  if(l!=0) //division is not possible if the denominator is 0.

  {

   x=k/l;

   printf("%.2f/%.2f=%.2f",k,l,x);

  }

  else  

   printf("Division result is undefined");

               default:

   printf("\n invalid operation");

}

}

Output is in image.

Explanation:

At first we take two numbers.

Then we take integers from 1 to 4 for Addition, subtraction, multiplication, division respectively.

Then accordingly the case is followed and the operation is performed.

You might be interested in
Yo need help can someone plz help
Natasha_Volkova [10]
Boolean search would be the answer
5 0
3 years ago
Which tool will be useful in darkening a subject’s hair color in a photograph? A.Dodge tool B.Burn tool C.Patch tool D.Blur tool
choli [55]
It's B. The burn tool darkens stuff. The dodge tool lightens stuff. hope this helps, have an amazing day :)
8 0
4 years ago
Read 2 more answers
You want to create a place on a Webpage where you can display graphics, animation, video and games "on the fly" without the need
AURORKA [14]

Answer:

Canvas.

Explanation:

The canvas API is used to create a place where you can display graphics on a webpage. You can also display video,games and animations there on the fly .You can do this without the need for a plug-in.

It is largely focused on 2-D graphics.This API uses canvas element of HTML.

<canvas>....</canvas>.

4 0
3 years ago
"ikev2 requires the use of which of authentication protocol?"
katen-ka-za [31]
Ikev2 requires the use of authentication protocol called Extensible Authentication Protocol (EAP).  It is <span>is a protocol for wireless networks that ampiflies on the authentication methods for the Point-to-Point Protocol (PPP).</span>
4 0
3 years ago
Write a function called st_dev. st_dev should have one
aleksandrvk [35]
Huluttttttt!!! greggyffh
8 0
2 years ago
Other questions:
  • Design the below using an array// Sunrise Freight charges standard// per-pound shipping prices to the five states they serve// –
    6·1 answer
  • The integer variables first and last have been declared and assigned values (with last &gt;= first). Allocate an integer array t
    10·1 answer
  • Productivity can best be described as:
    5·2 answers
  • The Leader Motive Profile (LMP) includes a: a. high need for power. b. low need for achievement. c. moderate need for power. d.
    6·1 answer
  • Cable television, as well as some networks, uses ________ cable.
    10·1 answer
  • How to reset maintenance light on toyota camry?
    12·1 answer
  • Find different between manocots and dicots clarify with example​
    14·1 answer
  • ___________ is a computer programming language.
    9·2 answers
  • What is the final step when creating an appointment to ensure that the content of the appointment is stored in Outlook?
    13·1 answer
  • If you delete search results, you will a. clear the history on the computer. b. delete files from our computer. c. modify the re
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!