answer.
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]
2 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]2 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
PLEASE HELP!! WILL GIVE BRAINLIEST!!
Lesechka [4]
I am pretty sure it is the fourth one

6 0
1 year ago
Read 2 more answers
Which expansion slot is used by an NVMe compliant device?
miskamm [114]

Answer:

3. PCIe

Explanation:

An expansion card is a slot on the motherboard of a computer which allow users use an additional feature such as network, video, sound that may not be available before.

PCIe is an expansion slot that is used by an NVMe compliant device. NVMe is the short form or acronym for “Non–Volatile Memory express. ”

5 0
2 years ago
Which Internet of Things (IoT) challenge involves the difficulty of developing and implementing protocols that allow devices to
dolphi86 [110]

Answer:

Option C i.e., Interoperability is the correct option

Explanation:

Interoperability performs for computers or its components for the purpose to communicate and it is important to improve the development of the Internet of Things. It performs the communication as well as share their services between computer or its components.

It also contains challenges occurred at the time of developing and implementing the protocols by which they communicate.

7 0
2 years ago
List three functions that you can perform with a database that you cannot perform with a spreadsheet.
Delicious77 [7]
There are some function which can be performed with database but not with a spread sheet, these functions include: 
1. Enforcement of data type.
2. Support for self documentation.
3. Defining the relationship among constraints in order to ensure consistency of data.
5 0
1 year ago
Why can a failure in a database environment be more serious than an error in a nondatabase environment?
Elina [12.6K]
Failure in a database environment is more serious then a non data base because if you lose important information you may not get it back and failure in a nondatabase environment the problem may be more easier to solve
5 0
1 year ago
Read 2 more answers
Other questions:
  • U.S. industries like steel, computers, and energy need to be protected from foreign competition to ensure which of the following
    6·2 answers
  • Open this link after reading about Ana's situation. Complete each sentence using the drop-downs. Ana would need a minimum of ato
    5·2 answers
  • ______ is a statistic that measures how quickly the staff corrected a network problem after they arrived at the problem site. MT
    9·1 answer
  • A key field is used to _____. enter a password uniquely identify records merge data list the most important information
    12·2 answers
  • Samuel received an email that looked like it came from his bank. The email told him to click a link that opened an official look
    7·1 answer
  • Suppose that each row of an n×n array A consists of 1’s and 0’s such that, in any row i of A, all the 1’s come before any 0’s in
    15·1 answer
  • Let's revisit our lucky_number function. We want to change it, so that instead of printing the message, it returns the message.
    10·1 answer
  • The geographic coordinate system is used to represent any location on Earth as a combination of latitude and longitude values. T
    5·1 answer
  • A credit card company receives numerous phone calls throughout the day from customers reporting fraud and billing disputes. Most
    10·1 answer
  • In Python, parentheses are used in calculations where the order of operations affects the outcome. (5 points)
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!