Author Topic: What's wrong with my calculator? :(  (Read 1116 times)

Why the forget did you message me three times about this and then make a thread for it?

Looks like you divided by zero.

wut
Since when do calculators read scripting languages?
Gtfo with your rich people calculators. ;-;
since the computer was invented...
damnit who here doesn't know that the computer is one big calculator
ib4Binary

Hmmp, I got one.

Code: [Select]
start caulc

You are using functions before they are declared.

http://en.wikipedia.org/wiki/Function_prototype

Thanks.

Why the forget did you message me three times about this and then make a thread for it?
Short attention span :(

Also, I'm not sure how to do this... But,

How can I make it return back to Main without using goto?


Figured it out.
Code: [Select]
#include <iostream>

using namespace std;

int addition(int a, int b) {
    return (a+b);
}

int multiplication(int a, int b) {
    return (a*b);
}

int division(int a, int b) {
    return (a/b);
}

int subtraction(int a, int b) {
    return (a-b);
}

int main() {
    int a;
    int b;
    int input;
    int result;
    do {
    cout << "Enter in a number\n";
    cin >> a;
    cout << "Now enter a second in\n";
    cin >> b;
    cout << "Now choose which operation you'd like\n";
    cout << "1. Addition\n";
    cout << "2. Multiplication\n";
    cout << "3. Subtraction\n";
    cout << "4. Divison\n";
    cin >> input;
    if (input == 1) {
        result = addition (a,b);
                    }
    else if (input == 2) {
        result = multiplication (a,b);
    }
    else if (input == 3) {
        result = subtraction (a,b);
    }
    else if (input == 4) {
        result = division (a,b);
    }
    cout << "The operator specified returned " << result << ".\n";
    } while (input != 1337);
    return 0;
}
Sweet, I now declare myself pro at functions.

On to classes/structures.