Help with Codeblocks calculator

I am very new to CodeBlocks and i am trying to make a simple calculator
And i cant get it to do anything but sum,i dont know what i am doing wrong

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
  #include <iostream>

using namespace std;

int main()
{
    int digit1;
    cout << "Enter your first digit, and then press enter" << endl;
    cin >> digit1;
    int digit2;
    cout << "Enter your second digit, and then press enter" << endl;
    cin >> digit2;
    int o;
    cout << "If you wish to add, press 1, and then enter" << endl;
    cout << "If you wish to suntract, press 2, and then enter" << endl;
    cout << "If you wish to multiply, press 3, and then enter" << endl;
    cout << "If you wish to divide, press 4, and then enter" << endl;
    cin >> o;
    if (o = 1)
    {
        cout << "The sum of your two digits is " << digit1+digit2 << endl;
    }

    else if (o = 2)
    {
        cout << "The difference of your two digits is " << digit1-digit2 << endl;
    }

    else if (o = 3)
    {
        cout << "The product of your two digits is " << digit1*digit2 << endl;
    }

    else if (o = 4)
    {
        cout << "The quotient of your two digits is " << endl;
        cout << "Quotient " << digit1/digit2 << endl;
        cout << "Remainder " << digit1%digit2 << endl;
    }

    else if (o > 4)
    {
        cout << "Invalid operation" << endl;
    }
    return 0;
}
change =
with ==

line 21
 
cout << "The sum of your two digits is " << (digit1+digit2) << endl;
Last edited on
Thank you very much
Topic archived. No new replies allowed.