Storing a result to loop/Order of operations

I need help with my finishing off my calculator with a an issue. I am unable to keep the result from the second operation to loop again, for example, 5*3= 15 -- it will just use the number 15 infinitely going forward. Thank you for your help in advanced!

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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
      #include <iostream>
    #include <cmath>
    using namespace std;


     double a = 0, b = 0, c = 0;
        char op, op2;
        double result, result2;

    int main(){
        cout << "Please enter a number followed by an operator followed by a number for a solution." << endl << endl;
        cout << "A few valid operators include: (+, -, *, / and R(Remainder))." <<
    endl << endl;
        cout << "Other operations include: (sqrt and ^)." << endl << endl;
        cin >> a >> op >> b;
            if (op == '*' )
                {
                result = a * b;
                }
                else if ( op == '/' )
                {
                    result = a / b;
                }
                else if ( op == '+' )
                {
                    result = a + b;
                }
                else if( op == '-' )
                {
                    result = a - b;
                }
                else
                {
                    cout << "Error: Invalid Operator" << endl << endl;
                }
                    cout << result << endl;

            while(true)
            {
                char op2;
                double c;
                double d;
                result == result2;
               cin >> op2 >> c;
                if (op2 == '*' )
                {
                    result2 = result * c;
                }
                else if ( op2 == '/' )
                {
                    result2 = result / c;
                }
                else if ( op2 == '+' )
                {
                    result2 = result + c;
                }
                else if( op2 == '-' )
                {
                    result2 = result - c;
                }
                else
                {
                    cout << "Error: Invalid Operator" << endl << endl;
                }
                result2 += result;
                cout << result2 << endl;
                if(op2 == true){
                    continue;
                }
              }


            }
result == result2;

What are you attempting to do here on line 43? Right now, this has no effect on the program.

== tests for equality
= is the assignment operator.

Hope that helps.
Basically im trying to loop the op2 while loop, for instance first ill put in something like 15+3, using that result ill have it result + c. So for the result + c im trying to figure out how to look the result of that again so I add/multiply etc to it again and again. Like a regular calculator where you add a number and get the result you can just add an operator and another number. Thanks for the help.
So does the behavior of your program change after you change line 43 to result = result2;?
It works perfectly, thank you very much!
Topic archived. No new replies allowed.