Write a program that simulates a simple calculation, C/C++ Programming

Assignment Help:

The program reads two numbers and a character (operator). If the character is "+" then sum is displayed. If it is "-"then difference is displayed. If it is "*" then product is displayed. If it is "/" then quotient is displayed. Use a switch statement.

#include 

using  namespace  std;
int  main  (  )

{

int  number1,  number2,  answer1,choice; float  answer2;

/*  menu  of  operation*/

cout<<"Menu  of  Operations"< cout<<"2  Division  "< cout<<"3  Addition  "< cout<<"4  Subtraction  "< /*end  of  menu*/

cout<<"enter  the  two  integer  numbers:  "<>number1>>number2;

cout<<"enter  your  choice:  "< cin>>choice;

/*  make  use  of  the  switch  case  construct
   to  make  decisions*/

switch  (choice)

{

case  1:

answer1=  number1  *  number2;

cout<

case  2:

answer2=  number1  /  number2;

cout<case  3:

answer1=  number1  +  number2;

cout<

case  4:

answer1=  number1  -  number2;

cout<

default:

cout<<"invalid  operator"<

}

return  0;

}


Related Discussions:- Write a program that simulates a simple calculation

Algorithms, create algorithm for doubly link list using c data structure

create algorithm for doubly link list using c data structure

Lexicographic permutation, given integer ''n'' and permutation of numbers 1...

given integer ''n'' and permutation of numbers 1,2,..n-1, c program to print permutation that lexicograghically precedes given input permutation if permutation is least print input

Amie, what happens when the following command is used? chmod u=rwx,go=r-x f...

what happens when the following command is used? chmod u=rwx,go=r-x foo

Described container class?explain types of container class, A container cla...

A container class is a class which is used to hold objects in external storage and memory. A container class work as a generic holder. A container class contains a predefined behav

FILES, My file pointer is going to the location which i specified and writi...

My file pointer is going to the location which i specified and writing the value but it is in next line so,please help me iam developing in visual studio6

Program that controls the lcd display, Objective:  Construct a C program...

Objective:  Construct a C program that controls the LCD display, and is capable of displaying strings.  Add functions to the C program that allows more control over the display.

Programming, what is the first thing I need to know about Programming?

what is the first thing I need to know about Programming?

Employee salary, wap to read an employee salary and calculate DA,HRA,pf,GRO...

wap to read an employee salary and calculate DA,HRA,pf,GROSS,NET conditions:- BASIC DA HRA PF >10000 7% 9% 10% & >20000 9% 11% 15% &

#title, Given an integer n and a permutation of numbers 1, 2 ... , n-1, n w...

Given an integer n and a permutation of numbers 1, 2 ... , n-1, n write a program to print the permutation that lexicographically precedes the given input permutation. If the given

#c++ homework, write c++programm that converts degrees Kelvin (TK) to degr...

write c++programm that converts degrees Kelvin (TK) to degrees Fahrenheit(TR) recall that TF=(9/5)TK and that TF=TR-459.67

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd