Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

I have a problem with my second program

$
0
0
Hey guys, I just learn what the if statment was and i thought of something, an interactive calculator, but when i tried to out i typed in addiction and i was hoping for it to let me tpye numbers after that but it just gave the numbers itself and I was wondering what did I do wrong. (no errors pop up).

#include <iostream>

using namespace std;

int main()
{
    int addiction;
    int subtraction;
    int multiplication;
    int division;

    cout << "what would you like to do addiction subtraction multiplication division" << endl;
    if (addiction) {
        int a;
        int b;
        int sum;
        cout << "type in a number \n";
    cin >> a;

        cout << "type in another number \n";
    cin >> b;

    sum = a + b;
        cout << "your number is " << sum << endl;

    }

    if (subtraction) {
        int a;
        int b;
        int sum;
        cout << "type in a number \n";
    cin >> a;

        cout << "type in another number \n";
    cin >> b;

    sum = a - b;
        cout << "your number is " << sum << endl;

    }

    if (multiplication) {
        int a;
        int b;
        int sum;
        cout << "type in a number \n";
    cin >> a;

        cout << "type in another number \n";
    cin >> b;

    sum = a * b;
        cout << "your number is " << sum << endl;

    }

    if (division) {
        int a;
        int b;
        int sum;
        cout << "type in a number \n";
    cin >> a;

        cout << "type in another number \n";
    cin >> b;

    sum = a / b;
        cout << "your number is " << sum << endl;
    }
return 0;
}

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>