C++ Program of Calculator

ad+1

Program:

// Program By http://solutionscpp.blogspot.com
// Author Mansoor Ahmed
// GMail ID: secguy000@gmail.com

#include<iostream>
using namespace std;

int main()
{
    int n1=0, n2=0;
    char c;
   
    cout<<"Enter 1st number: ";
    cin>>n1;

    cout<<"Enter 2nd number: ";
    cin>>n2;   
   
    cout<<"Enter Operator: ";
    cin>>c;
   
    switch(c)
    {
        case '+':
        cout<<"Sum is: " <<n1+n2;
        break;
       
        case '-':
        cout<<"Difference is: " <<n1-n2;
        break;
       
        case '*':
        cout<<"Prduct is: " <<n1*n2;
        break;
       
        case '/':
        cout<<"Division is: " <<n1/n2;
        break;
       
        default:
        cout<<"Invalid Operator!" <<endl;
    }
   
}
   

Output:

0 comments: