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

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;

}

Posted Date: 8/21/2012 11:19:05 AM | Location : United States







Related Discussions:- Write a program that simulates a simple calculation, Assignment Help, Ask Question on Write a program that simulates a simple calculation, Get Answer, Expert's Help, Write a program that simulates a simple calculation Discussions

Write discussion on Write a program that simulates a simple calculation
Your posts are moderated
Related Questions
Define Multi File Program? While writing large programs we must divide programs up into modules. These would be separate source files and the main() function would be in one fi

Hello. I need a solution for this assignment. It is for C++ Language: Create a BusinessPartner class that contains a first name, company name, and a telephone number. Create a Con

flow chart for push operation in stack

•Flow Chart and Pseudocode of Add module - Hotel booking - Signup for new membership Delete module - Hotel reservation cancellation - Change of reservation

How can I handle a constructor that fails?

Define How Passing Arrays to a Function? A complete array can be passed to a function as an argument. The manner in which the array is passed be different from that of an ordin


To write a program to use different levels of array of pointer to pointer & display the output as 1 1 1 2 2 2 3 3 3

decoding message