/* Calculator that performing as calculator which allows all Arithmatic Operators with operands as input */

/* Author Name: Md.Naimul Hasan Shohan */

 

#include<iostream>

#include<stdlib.h>

#include<conio.h>

using namespace std;

int calculator(int a,char c,int b)

{

 

    int h,w,x,z;

    float y,m=0.0;

    z=(a+b);

    x=(a*b);

    w=(a-b);

    h=(a%b);

    y=(a/b);

    m=y;

 

    switch(c)

    {

    case '+':

        cout<<a<<"+"<<b<<"="<<z<<endl;

        break;

 

    case '-':

        cout<<a<<"-"<<b<<"="<<w<<endl;

        break;

 

    case '*':

        cout<<a<<"*"<<b<<"="<<x<<endl;

        break;

 

    case '/':

        cout<<a<<"/"<<b<<"="<<m<<endl;

        break;

 

    case '%':

        cout<<a<<"-"<<b<<"="<<x<<endl;

        break;

 

    default:

        cout<<"Error Input Program Terminated"<<endl;

        break;

    }

 

    getch();

    return 0;

}

 

int main()

{

    int a,b,x;

    char c,y;

    cout<<"Welcome To My Calculator:"<<endl;

    cout<<"Enter to calculate:"<<endl;

    start:

    cin>>a>>c>>b;

 

    calculator(a,c,b);

    cout<<"If you want to calculate more then press Y else N"<<endl;

    cin>>y;

    if(y=='y' || y=='Y')

    goto start;

    else if(y=='N' || y=='n')

    exit(0);

}

 

 
     
  Back to Main Page