Calculator proramm in c++ simple code

April 25, 2013

Calculator proramm in c++ simple code

Make a four function calculator. Read in two numbers and a mathematical operator. Add the two numbers if the operator ‘+’ is entered. Subtract the two numbers if operator ‘-‘is entered and so on. Display the calculated result. If any character other than +,-,*, /is entered, display proper error message.

                       Step1:    Start
                       Step2:    Declare num1,num2,
                       Step3:    Declare character ( + , - , * , / )
                       Step4:    Input num1 & num2
                       Step5:    Input sign like ( + , - , * , / )
                       Step6:    Display Calculation 
                       Step7:    End

# include <iostream>
using namespace std;

int main ()
            int num1,num2;
            char sign;
 cout<< "Enter 1st number="<<endl;
 cin>> num1;

 cout<<"Enter 2nd number="<<endl;
 cin>> num2;

 cout<< "Enter sign\n=";
 if (sign=='+')
 else if (sign=='-')
 else if (sign=='*')
             cout<< num1*num2<<endl;
 else if (sign=='/')
             cout<< num1/num2<<endl;
             cout<<"You have enter an invalid sign"<<endl;
 return 0;

flow chart of calculator C++

how to make calculator in c++

You Might Also Like


Popular Posts

Like us on Facebook

Flickr Images