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
You have implemented a network where hosts are assigned specific roles, such as for file sharing and printing. Other hosts acces
yulyashka [42]

<u>Client-server</u> implemented a network where hosts are assigned specific roles, such as for file sharing and printing. Other hosts access those resources but do not host services of their own.

<u>Explanation:</u>

The client-server can be utilized on the web just as on a neighborhood (LAN). Instances of customer server frameworks on the web incorporate internet browsers and web servers, FTP customers and servers, and the DNS. Different hosts get to those assets yet don't have administrations of their own. Since it permits arrange permits numerous PCs/gadgets to interface with each other and offer assets.

5 0
3 years ago
A type of touch screen that can be up to four feet by six feet is a(n) _____.
Llana [10]
Hi,

A type of touch screen that can be up to four feet by six feet is a(n) <span>multitouch interface.
</span>.
7 0
2 years ago
Read 2 more answers
What is the primary difference among a domain model, an analysis model, and a design model for the same project?
Aleks04 [339]

Answer:

The design model is the description of the model to be implemented, the analysis model is the model that links the design and the system or domain model while the domain model is the entire software implementation.

Explanation:

The domain model is the conceptual aspect of software engineering that comprises operational and data features. The analysis model is the schematic description of the system that links the design model to the system domain. The design model is also known as the object model as it shows an abstract representation of the implementation. It helps to test the quality of the software been developed.

8 0
2 years ago
A new user needs access to their files in iCloud without relying on the operating system (OS). How would the user access the App
m_a_m_a [10]

Answer:

Log in to iCloud.com on a browser

Explanation:

On your browser which should be a supported browser, you should log in to iCloud.com since iCloud is not supported on mac OS X earlier than mac OS X Lion 10.7.5

7 0
2 years ago
How can you stay safe on the Internet? Check all that apply.
Harlamova29_29 [7]

Answer:

all of the above

Explanation:

7 0
3 years ago
Read 2 more answers
Other questions:
  • The World Wide Web consists of interconnected computer networks throughout the world that everyone can use. True or False
    13·2 answers
  • Which is the correct sequence of steps for opening a new document?
    10·2 answers
  • Can anyone find any words in here?
    14·2 answers
  • Write a program to calculate the great circle distance between two points on the surface of a sphere. If p1(x1, y1) and p2(x2,y2
    5·1 answer
  • Assume variables SimpleWriter out and int n are already declared in each case. Write a while loop that printsA. All squares less
    11·1 answer
  • Example of negative body language include all but
    8·1 answer
  • It connects computers in different cities and different countries
    9·2 answers
  • - O conhecimento na Educação Física, normalmente passa do senso comum e vai para um conhecimento mais formal, ou seja, do conhec
    7·1 answer
  • I have all of the points and brainliest, but it won't level up, I don't know why, anyone know why?
    12·2 answers
  • 30 POINTS PLS HELLLLPPP WILL GIVE BRAINLIEST What behavior do elements in a stack follow? first in, last out, or FILO behavior l
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!