I am learning C++ from an online resource. I tried to test part of there code and it isn't working. Here is the code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
#include "stdafx.h"
#include <iostream>
using namespace std;
int main()
{
int age1, age2, age3, age4, age5; // These two lines are meant to
int TotalAge, Averageage; //are meant to declare my variables
{
cout<< "Please enter the age of student 1:"; // The next number of lines ask for the input
cin>> age1; // of the different ages.
cout<< "Please enter the age of student 2:";
cin>> age2;
cout<< "Please enter the age of student 3:";
cin>> age3;
cout<< "Please enter the age of student 4:";
cin>> age 4;
cout<< "Please enter the age of student 5:";
cin>> age5;
TotalAge = age1 + age2 + age3 + age4 + age5; //The next two lines work to determine the average age
AverageAge = TotalAge / 5
cout<< "Average age of class is:" <<AverageAge;
}
}
|
The errors that i get are as follow:
1>------ Build started: Project: 123, Configuration: Debug Win32 ------
1> 123.cpp
1>123.cpp(19): error C2065: 'age' : undeclared identifier
1>123.cpp(19): error C2143: syntax error : missing ';' before 'constant'
1>123.cpp(23): error C2065: 'AverageAge' : undeclared identifier
1>123.cpp(24): error C2146: syntax error : missing ';' before identifier 'cout'
1>123.cpp(24): error C2065: 'AverageAge' : undeclared identifier
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I could really use some help please. Thank you. (By the way im kinda new to commenting on my program. I wasn't sure if you guys would need it.