Serbian Kings

Would you like to react to this message? Create an account in a few clicks or log in to continue.
Serbian Kings

Forums for you...


    C++ CALCULATOR (make calculator)

    fondza [Admin]
    fondza [Admin]
    Admin
    Admin


    Posts : 123
    Join date : 2009-10-03

    C++ CALCULATOR (make calculator) Empty C++ CALCULATOR (make calculator)

    Post by fondza [Admin] Sat Oct 17, 2009 11:08 am

    This is a simple C++ Calculator.
    It can get confused sometimes if there are too many digits but if you want to change

    Code:
    int b,c;

    or any of the other int's to long, then it will work fine too.
    Tell me if it doesn't work for you.

    Code:
    #include <iostream>
    using namespace std;

    int main()
    {
    int a;
    cout<<"witch opperation would you like to do\n";
    cout<<"for addition press 1\n";
    cout<<"for subtraction press 2\n";
    cout<<"for multiplication press 3\n";
    cout<<"for division press 4\n";
    cout<<"\n";
    cin>> a;
    cin.ignore();
    if (a==3)
    {
    int b,c;
    cout<<"what is the first number you would like to multiply? ";
    cin>> b;
    cin.ignore();
    cout<<"what is the second? ";
    cin>> c;
    cout<<""<< b*c <<"";
    cin.get();
    cin.get();
    }
    if (a==1)
    {
    int d,e;
    cout<<"what is the first number you would like to add? ";
    cin>> d;
    cin.ignore();
    cout<<"what is the second? ";
    cin>> e;
    cout<<"" << d+e <<"";
    cin.get();
    cin.get();
    }
    if (a==2)
    {
    int f,g;
    cout<<"what is the first number you would like to subtract? ";
    cin>> f;
    cin.ignore();
    cout<<"what is the second? ";
    cin>> g;
    cin.ignore();
    cout<<"" << f-g <<"";
    cin.get();
    cin.get();
    }
    if (a==4)
    {
    int h,i;
    cout<<"what is the numerator? ";
    cin>> h;
    cin.ignore();
    cout<<"what is the denomanator? ";
    cin>> i;
    cin.ignore();
    cout<<"" << h/i <<"";
    cin.get();
    cin.get();
    }
    }

      Current date/time is Sat May 11, 2024 11:28 am