expected ';' before 'endl'

Just tinkering around with some code, am very new to C++.

For some reason this error keeps popping up, not just in this program but in other simple ones I've tried as well.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <iostream>
using namespace std;

int a, b, c;

int main()
{
    cout << "Have your quadratic in the form ax^2 + bx + c" endl;
    cout << "Enter in the value of a and press ENTER" endl;
    cin >> a;
    cout << a;

    return 0;
}


The error is reporting to be on lines 8 & 9

Any help would be appreciated :)

Tom
If you want to output multiple items, use << between each. That includes putting << before endl.
1
2
3
    int a = 5, b = 7, c = 11;
    cout << a << " " << b << endl;
    cout << c << endl;
Last edited on
Ah ok, so on line 8, even though there was only one line to output you have to put the greater than symbols either side of an output. Does that count for inputs too?

ie.

cin >> "a" >> endl;

or would cin >> "a" endl; work ok?
^^ I just realised how stupid that was. Don't think you need endl; after an input because your not printing anything. -Facepalm-
you have to put the greater than symbols either side of an output

That's not quite the way to look at things. We are not "surrounding" an item with the insertion operator <<. Rather, we are separating each item, when there is more than one.
Topic archived. No new replies allowed.