Variable not declared?

Just trying to write something to sum and average three numbers but it says "expected unqualified-id before '<<' token (line 13)" and 'a' was not declared in this scope (same for b and c) (lines 14 and 16), help please!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
  #include <iostream>

using namespace std;

int add (double x, double y, double z)
{
    return x + y + z;
}

int main ()
{
    cout << "Enter three numbers:" << endl;
    double << a, b, c;
    cin >> a >> b >> b;

    cout << "The sum of your numbers is: " << add (a, b, c) << endl;
    cout << "The mean of your numbers is: " << add(a, b, c) / 3 << endl;

    return 0;
}
Remove << from line 13.
line 13 - do you mean to just declare the three variables a, b and c there? If yes, take out the << so it's just double a, b, c;


Edit: If you're allowing doubles to be entered into the add function, I'd change the return type to be double instead of int.
Last edited on
Thank you both!
Topic archived. No new replies allowed.