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
State one device that may be found on a computer monitor that is used for video conferencing
torisob [31]

Answer: Camera and Microphone

Explanation:

This can be  embedded on to the monitor.m

Camera for Visual

Microphone for radio.

5 0
2 years ago
the two main ways in which marketers address the competition with their strategies are by satisfying a need better than a compet
Nonamiya [84]

Offering a lower price (Apex)

4 0
3 years ago
Read 2 more answers
L
Artist 52 [7]

Answer:

I tried, I falid, I sorry :(

Explanation:

......

5 0
3 years ago
To refine the in-between motions, a computer animator uses a mathematical function called a(n)
RoseWind [281]

Answer:

tweening

Explanation:

4 0
4 years ago
Whos really watching this guys bruh​
Ivahew [28]

Answer:

Me no

Explanation:

4 0
3 years ago
Read 2 more answers
Other questions:
  • What type of wireless connection requires an unobstructed "line of sight" between transmitter and receiver?
    8·1 answer
  • 1.   Which of the following is an example of a primary cost of an accident or injury?
    5·2 answers
  • Can rank u r guys in rocket leagye
    13·1 answer
  • In what Career Cluster you get to design, build, and destroy things
    6·1 answer
  • What is the name for the last word on a dictionary page?
    13·1 answer
  • Which of the following scenarios describes an advantage of a global economy?
    9·1 answer
  • Qbasic program to check whether an entered number is positive or negative or neutral​
    15·1 answer
  • As a hardware technician and knowing the internet components of the system unit, list any five(5) of such components.
    6·1 answer
  • ____ includes) all tools that capture, store, process, exchange, and use information.
    9·1 answer
  • you are working in the headquarters of an organization and you're asked to deal with the interruption in services due to network
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!