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]
3 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]3 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
What will happen when a user attempts to login to salesforce from an ip address that is outside the login ip range on the user's
podryga [215]

Answer:

The answer to this question is option "d".

Explanation:

The answer is user will not be able to login at all. The user wants to log in to the salesforce by its IP address. But in the server, all the IP addresses will be registered for their special work. When the user inserting their IP address to log in to the salesforce. The first server will be checking into there database. If IP address doesn't match it will not permit to access salesforce because in their server it is not a valid IP address. It is registered in sever but not for this user.

So the answer to this question is option "d".

7 0
3 years ago
Which of the following statements is true of alert files?
ozzi

Answer:

They are only generated by Wireshark.

3 0
2 years ago
Which of the following is not an advantage of concurrent design?
viva [34]

The answer I believe is B

7 0
3 years ago
Read 2 more answers
write query for all products reutrn product name with its amounts due, paid, canceled, and refunded, order the result by product
spayn [35]

Answer:

SELECT product_name, amount_due, amount_paid,

              cancelled, amount_refunded

   FROM products

ORDER BY product_name ASC;

Explanation:

SQL (Structured Query Language ) was used above.

The SELECT command is used to list all the variables we want in our output.

The FROM command signifies the location.

ORDER BY command ensures that your result is ordered

ASC means Ascending Order.

; signifies the end of the query.

NOTE: Underscores were used because variables cannot be written with spaces between them

8 0
2 years ago
This has nothing to do with anything school related, but I'm new to car audio and I was wondering, what happens or what would ha
DerKrebs [107]
It most likely can but It may damage your system. So you should seek out professional help from a car dealership and do more research.

Hope this helps.<span />
7 0
2 years ago
Other questions:
  • Why does the PC send out a broadcast ARP prior to sending the first ping request
    12·1 answer
  • An ethernet switch has a ____ table which is updated by ______.
    14·1 answer
  • In DTP, a good rule of thumb is to use as many special effects as you need to make your documents look interesting.
    5·1 answer
  • Match the personality traits with their description
    9·2 answers
  • What are the benefits of maintaining your vehicle?
    5·2 answers
  • How can you create an illusion of spatial depth in a two-dimensional design?
    15·1 answer
  • Which of the following is NOT a type of insurance fraud?
    14·2 answers
  • Leon needs to configure the days and times of his work week for his Outlook Calendar. Which option should he
    12·2 answers
  • Noi needs to send some documents to a client in another company. Which device can she use to make digital copies of the paper fi
    13·2 answers
  • Please help me on this match all this up i’ll give you brainlist
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!