Theres an error...

So, Im new to programming and just read some of the tutorials. I started programming, thought I should make an easy calculator. Here it is.

#include <iostream>

using namespace std;

int main(){

    int a;
    int b;
    int c;
    int d;

    cout << "In what way would you like your calculator to count in?\n";
    cout << "1) Addition\n";
    cout << "2) Subtraction\n";
    cout << "3) Multiplication\n";
    cout << "4) Division\n";
    cout << "Enter a choice: ";
    cin >> a;

    switch (a){

        case 1:
            cout << "Enter a number: ";
            cin >> b;

            cout << "Enter a second number: ";
            cin >> c;

            d = b+c

            cout << "The sum is " << d << "\n";

            break;

        case 2:
            cout << "Enter a number: ";
            cin >> b;

            cout << "Enter a second number: ";
            cin >> c;

            if (b > c){

                d = b-c

                cout << "The sum is " << d << "\n";

                break;

            } else if(b == c){

                cout << "Well, thats 0...";

                break;

            } else {

                cout << "That wont work!";

                break;

            case 3:
                cout << "Enter a number: ";
                cin >> b;

                cout << "Enter a second number: ";
                cin >> c;

                d = b*c

                cout << "The sum is " << d << "\n";

                break;

            case 4:
                cout << "Enter a number: ";
                cin b;

                cout << "Enter a second number: ";
                cin c;

                d = b/c

                cout << "The sum is " << d << "\n";

                break;

            default:
                cout << "Not a valid entry...";

                break;

        }

}


Very simple, yes. So, when I tried to compile it it came some errors, most very clear. I cleared them all but one.

"In function `int main()':
expected `}' at end of input
[Build Error] [Objects/MingW/Calculator.o] Error 1"

Input? I thought they meant the function at first, cant be that one, as I already have on there. I dont have an input, atleast not one that should be followed with }.
Am I wrong? Correct me, help me! Also, Im using wxDev-C++, if you think the compiler is the problem.
Add return 0; before the last } and add ; after the d = b+c and similar processes. You also need to check your cin's because it needs >> right? Like in the first cin's that you did :p
Last edited on
You missed a } at the end of case 2: else condition...
return 0; shouldn't make a difference
Yup, it won't... Though all the missing semi-colons will!!! as well as the missing }...
I did as you said Caprico, worked out well. Funny I occured another error.

"cannot find -lwxmsw28
id returned 1 exit status
[Build Error] [Output/MingW/Calculator.exe] Error 1"

I had this problem early in my tutorials. I searched it, and found out atleast this one was spefically for wxDev-C++. Other blogs I read about it didnt work, I supposed it was because of older versions. Now, how about helping me with that?
Use a different software! :P I use TurboC++... CodeBlocks is even better, coz it will help you in the future languages as well....
Meh. Ill consider it :P
Topic archived. No new replies allowed.