Automatic calculator error

I have copied and made a better version of a automatic calculator in another archived forum. I made it so whenever you enter n, a new equation starts. It works but it says "n5" or something like that. Here is the code

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
#include <cstdlib>
#include <iostream>
using namespace std;
float a,c,n,m;
char b,d;
inline float addizione(float a, float c){      //Function +
        return m=a+c;
}
inline float sottrazione(float a, float c){  //Function -
        return m=a-c;
}
inline float divisione(float a, float c){    //Function /
        return m=a/c;
}
inline float moltiplicazione(float a, float c){    //Function *
        return m=a*c;
        }
int main()
{
    cout << "This calculator will loop, to start a new equation, input n for new \nIgnore the nx, x represents any number, and keep on using it like before" << endl;
    LOOP1:
    cin >> a;     // insert first integer
    LOOP:
    cin >> b;       // insert +-/*
    cin >> c;              // insert second integer
    cout << a;
    cout << b;
    cout << c;
    if(b=='+'){
        n=addizione(a,c);
        cout << "=" << n << "; \n";
        a=n;
        }
    else if(b=='-'){
        n=sottrazione(a,c);
        cout << "=" << n << "; \n";
        a=n;
        }
    else if(b=='/'){
        n=divisione(a,c);
        cout << "=" << n << "; \n";
        a=n;
        }
    else if(b=='*'){
        n=moltiplicazione(a,c);
        cout << "=" << n << "; \n";
        a=n;
        }
    if(b=='n'){
    goto LOOP1;
    }
    if(b=='+'){
    goto LOOP;
    }
    if(b=='-'){
    goto LOOP;
    }
    if(b=='*'){
    goto LOOP;
    }
    if(b=='/'){
    goto LOOP;
    }
system("pause");
return 0;
}
when you enter 'n' on line 24, you then have to enter c on line 25. after that you get a, 'n' and c printed and only then you jump to LOOP1 from line 50.
a quick solution would be to move lines 49-51 after line 24. though your whole program could use some improved structure.
Topic archived. No new replies allowed.