i thought it was. if i type std:: in my compiler getchar() comes up as a possible match plus i get no errors..oh well live and learn. im using vc express 2010. that annoys me a little.
Looking at it, I can't be sure if it's meant to be or not. Some implementations do have it in std:: namespace, some don't...
I'll check the authority. I trusted the compiler I'm using (g++ (Ubuntu 4.4.3-4ubuntu5) 4.4.3) when it produced that error message, but to be honest it's as likely to be non-standard as the MS C++ compiler.
When you write int iaverage_player_hrs you're trying to create a new variable called iaverage_player_hrs. If you already have one, it won't work.
'iavarage_player_hrs' : undeclared identifier
This means that you have never created anything called iavarage_player_hrs . Looknig at your code, I can see that this is true; you have not created this variable anywhere.
Run-Time Check Failure #3 - The variable 'iavarage_player_hrs' is being used without being initialized.
This means that you are using the value of a variable called iavarage_player_hrs but you have never actually set it to equal anything, so there could be any value in there.
As an aside, average is spelled with an "e" after the "v".
moschops your right its not in the namespace std. it says if it is next to the tooltip when it suggests it. but if its not why suggest it in the first place. plus why no errors. i can blame intellesense on mixing up std and non standard but the compiling when its not kinda annoys me.
This means that you are using the value of a variable called iavarage_player_hrs but you have never actually set it to equal anything, so there could be any value in there.
As an aside, average is spelled with an "e" after the "v".
//Code tested on Linux!
#include <iostream>
usingnamespace std;
int main()
{
int iPlayers;
int iHours;
int iPoints;
int iGames;
int iaverage_player_hrs;
cout << "Enter in The Total Number of Players: " << endl;
cin >> iPlayers;
cout << "Enter in The Total Number of Hours Played: " << endl;
cin >> iHours;
cout << "Enter in The Total Number of Points Scored: " << endl;
cin >> iPoints;
cout << "Enter in The Total Number of Games Played: " << endl;
cin >> iGames;
iaverage_player_hrs = iHours/iPlayers;
cout <<" The average player Hours are: " << iaverage_player_hrs << endl << endl;
int iaverage_player_points = iPoints/iPlayers;
cout <<" The average player points are: "<< iaverage_player_points<<endl<<endl;
int iaverage_points_game = iPoints/iGames;
cout <<" The average game points are: "<< iaverage_points_game <<endl<<endl;
int iaverage_points_per_hour_per_player = iaverage_player_points/iaverage_player_hrs;
cout << " The average points per hour per player are: " << iaverage_points_per_hour_per_player << endl;
cin.get(); //this should fix your winblows problem
return 0;
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Enter in The Total Number of Players:
5
Enter in The Total Number of Hours Played:
50
Enter in The Total Number of Points Scored:
500
Enter in The Total Number of Games Played:
5
The average player Hours are: 10
The average player points are: 100
The average game points are: 100
The average points per hour per player are: 10
The purpose of the program is to learn how things work and understand the fundamentals of C++. If this was meant to be 100% professional and absolutely perfectly working code, then I suspect he wouldn't be on these forums asking questions. Please, do use your brain when assisting the less-informed.