Simple Calculator Program In C++

Simple Calculator Program In C++

Here's the code for simple calculator program in C++:

#include <iostream>

using namespace std;

class calculator
{
public:
    void add(){
        int a,b;
        cout << "Enter first number:";
        cin >> a;
        cout << "Enter second number:";
        cin >> b;
        cout << "addition is :" << a+b;
    }
    void sub(){
        int a,b;
        cout << "Enter first number:";
        cin >> a;
        cout << "Enter second number:";
        cin >> b;
        cout << "subtraction is :" << a-b;
    }
    void multi(){
        int a,b;
        cout << "Enter first number:";
        cin >> a;
        cout << "Enter second number:";
        cin >> b;
        cout << "multiplication is :" << a*b;
    }
    void divi(){
        int a,b;
        cout << "Enter first number:";
        cin >> a;
        cout << "Enter second number:";
        cin >> b;
        cout << "division is :" << a/b;
    }
};
int main()
{
    calculator calc;
    int get;
    for(int i=1;i>0;i++)
    {
        cout << "\n\nPress:\n\t1 : addition\n\t2 : subtraction\n\t3 : multiplication\n\t4 : division\n\t0 : quit\n";
        cin >> get;
        if(get==1){
            calc.add();
        } else if(get==2){
            calc.sub();
        } else if(get==3){
            calc.multi();
        } else if(get==4){
            calc.divi();
        } else{
            break;
        }
    }
    return 0;
}


Output:

SIMPLE CALCULATOR IN C++

1 Comment. Leave new

You can even enjoy an 코인카지노 interactive story-driven slot recreation from our “SlotoStories” series or a collectible slot recreation like ‘Cubs & Joeys”! The greatest approach to discover out is to spin and see what suits you greatest. You have been warned lol .It simply retains getting better - usually I get bored with slot games, but not this one, although. Jackpot” in 1916, whereby sure combos of symbols on the reels regurgitated all of the cash within the machine.

Reply

Make sure you tick the "Notify Me" box below the comment form to be notified of follow up comments and replies.