What are the error messages?
(it looks like you're missing the std:: qualification on cout, endl etc. The best way to deal with that in your case is to put
using std::cout;
using std::endl;
using std::cin;
at the top and leaving the rest of the code alone. Note that you could use a blanket using namespace std; at the top, but that's a bad habit to get into, as it pollutes your namespace, rendering all of the hundreds of names housed in std:: unusable for anything else, or worse, causing conflict with your functions and variables of the same name.
jonsca
Quantitative Phrenologist
5,621 posts since Sep 2009
Reputation Points: 1,165
Solved Threads: 583
Skill Endorsements: 11
Get rid of lines 4-7. You can't have 2 mains in your program. It can't find the .exe file to start it because the code is not compiling successfully. Monitor the messages at the bottom of the Visual C++ screen to see the errors in your compilation. Double click on them to bring you to the line that has the error.
This is in no way your fault, Microsoft is trying to generalize main to be able to handle different encodings, and it's confusing as all get out when you're first getting started. :)
jonsca
Quantitative Phrenologist
5,621 posts since Sep 2009
Reputation Points: 1,165
Solved Threads: 583
Skill Endorsements: 11
Question Answered as of 1 Year Ago by
jonsca Not the chief concern, but take off the loop in 26, there's no need to output the same average 10 times.
Also, in C++ (and C99) you can declare the loop variable within the for loop
for (int k = 0;k<10;k++)
{
//k is available here
}
//k does not exist out here
You're missing your closing brace, but I think that might have been a copy/paste error.
How are you running your program? Try running it at a prompt. I was able to get the correct result.
jonsca
Quantitative Phrenologist
5,621 posts since Sep 2009
Reputation Points: 1,165
Solved Threads: 583
Skill Endorsements: 11