Cannot get program to compile

I'm trying to compile a basic program and I keep getting errors that cout is an undeclared identifier. The relevant code is below. I'm working with "Beginning C++ Through Game Programming" Third Edition, and I'm using Visual C++ 2010 Express on Windows 7 64-bit.

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
  #include "stdafx.h"


using namespace std;

int main()

{

	int firstScore, secondScore, thirdScore;

	float avgScore;

	avgScore = (firstScore+secondScore+thirdScore)/3;


	cout <<"Enter first score: ";

	cin >>firstScore;


	cout <<"Enter second score: ";

	cin >>secondScore;


	cout <<"Enter third score: ";

	cin >>thirdScore;


	cout <<"The average score is: ", avgScore;

	return 0;

}
To use cin and cout you need to put
#include <iostream> at the top of the program.
In addition to what Chervil said:

Line 14 will result in integer division (change 3 to 3.0),
Line 14 is working with uninitialized data (move that statement to line 31),
Line 32, though syntactically correct, is not what you want (replace the comma with <<)
Yup, took seventeen Google searches to find my missing iostream. I changed the order of my function and it works fine.
Topic archived. No new replies allowed.