error: expected ';' before 'std'

I'm bored so I made a simple calculator and I haven't completely finished it BUT I cannot seem to figure out what's wrong with the code. plshelp.

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

int main()
{
    int a;
    int b;
    std::cout << "What's your number brotherham?: " std::endl;
    std::cin >> a;

    std::cout << "Next number my niggy: " std::endl;
    std::cin >> b;

    int choice = 0;

    std::cout << "What operation would you like to perform?" std::endl;
    std::cout << "1. addition\n2. subtraction\n3. multiplication\n4. division" std::endl;

    if(choice == 1)
    {
        int c = a + b;
        std::cout << "Sum issssssssssssss " << c << ".";
    }
    if(choice == 2)
    {
        int c = a - b;
        std::cout << "Difference isssssssss " << c << ".";
    }
    if(choice == 3)
    {
        int c = a * b;
        std::cout << "Product isssssssss " << c << ".";
    }
    if(choice == 4)
    {
        int c = a / b;
        std::cout << "Divisor issssssssss " << c << ".";
    }



    return 0;
}


im going to but an else statement in there and instead of using int for my a and b variables i used float but i changed it to see if that was the problem. plshelp.
You need to put << before std::endl, just like you do for variables, strings, etc.
This:
std::cout << "What's your number brotherham?: " std::endl;

You can't put endl right after a string literal like that. If you want to send them both to cout, you have to use the << operator.

You probably meant to do this:

std::cout << "What's your number brotherham?: " << std::endl;

You have that same problem on like 3 other lines as well.
Last edited on
i forgot about that thanks!
Compilers usually tell the line number for the error too. Why should we have to guess?

Anyway, I would guess that 8, 11, 16, and 17 could give such error.
Topic archived. No new replies allowed.