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
Write a Program for Calculating Value of an Integer? For a clear understanding of recursive function we shall see an illustration for calculating value of an integer. main() {


At a shop of marbles, packs of marbles are prepared. Packets are named A, B, C, D, E …….. All packets are kept in a VERTICAL SHELF in random order. Any numbers

application problem of tower of hanoi

Define Advantages of Multi File Program? The main merits of spreading a program across several files are: • Teams of programmers able to work on programs. Every programmer w

I need plugin for amibroker using c++ Project Description: Need to prepare plugin for amibroker using c++. Should be system bound after installing. System should show based o


how to create a shopping cart

Is it possible to have Virtual Constructor? If yes, how? If not, Why not possible?

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