noob need help...

i have just started learning c++
i don't know what's missing, the same errors all over...


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
#include <iostream>

using namespace std;

int main()
{
    int a;
    int x;
    int y;
    int sum;
    int decimal;
    LOOP:
    cout << "select calculation method" << endl;
    cin >> a >> endl;
    cin >> x >> endl;
    cin >> y >> endl;
    if (a=='+'){
        cout << "write the firest number" << endl;
        cin >> x >> endl;
        cout << "write the second nuber" <<endl;
        cin >> y >> endl;
        sum = x + y;
        cout << sum;
    }
    if (a=='-'){
        cout << "spriv in ditt første tall" << endl;
        cin >> x >> endl;
        cout << "skriv in ditt andre tall" <<endl;
        cin >> y >> endl;
        sum = x - y;
        cout << sum;
    }
    if (a=='*'){
        cout << "spriv in ditt første tall" << endl;
        cin >> x >> endl;
        cout << "skriv in ditt andre tall" <<endl;
        cin >> y >> endl;
        sum = x * y;
        cout << sum;
    }
    if (a=='/'){
        cout << "spriv in ditt første tall" << endl;
        cin >> x >> endl;
        cout << "skriv in ditt andre tall" <<endl;
        cin >> y >> endl;
        sum = x / y;
        decimal = x% y;
        cout << sum;
        cout << "."decimal << endl;
    }
    goto LOOP;
    system ("pause")
    return 0;
}
You are trying to take input from the keyboard and store it in endl. This is insane. endl is not something you can store data in.

This:
cin >> a >> endl;
should be
cin >> a;


I see you are using goto to simulate a proper loop. Please do not. Not even for practice, not even because it's all you know. Since this is an infinite loop, you can use this:

1
2
3
4
while(1)
{
 // your code to loop forever
}
Topic archived. No new replies allowed.