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

Structure of cpp program, Structure of C++ Program: Chronological orde...

Structure of C++ Program: Chronological order of C++ program. 1.   Class declaration 2.   Main function program 3.   Member functions definitions 4.   Include heade

Arrays, how to declare multi dimensional array

how to declare multi dimensional array

Webcam driver static library or dll required for windows, Webcam Driver sta...

Webcam Driver static library or DLL required for Windows I want a .dll or .lib file using which i will take a snapshot from the webcam and it can't turn on the webcam LED while

Program to display asterisks in the shape of a plus sign, Write a program c...

Write a program called plus that will display asterisks in the shape of a plus sign which has the height and width specified by the user. You must only allow entry of an odd numb

Programming C/C++ need a answer, 3. Write a program to encrypt and decrypt...

3. Write a program to encrypt and decrypt strings of characters using the following ciphers: a) Caesar cipher b) Vigenere cipher c) Matrix transposition cipher Your program shoul

Explain the bitwise-inclusive-or operator, Explain the Bitwise-Inclusive-OR...

Explain the Bitwise-Inclusive-OR Operator: |? The bitwise-inclusive-OR operator (|) contrast each bit of its first operand to the corresponding bit of its second operand and if

Function, give an example of function

give an example of function

Area under curve, Write a program to find the area under the curve y = f(x)...

Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b.   #include float start_poin

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