Well I must be really dumb because even with all your help, I'm not getting this right.
I took out the global variable, put a local one. But I'm still not understanding how to pass this variable from one function to another.
Here's what I did:
Code:
void getScore(int& score)
{
std::cout << "Please input the grade score: ";
std::cin >> score;
score= score + score;
std::cout << "You entered the score of "<<score<<endl;
}
void printGrades(int score)
{
if (score >= 0 && score <= 59)
{
std::cout << "The grade is an F.";
}
else if (score >= 60 && score <= 69)
{
std::cout << "The grade is a D.";
}
else if (score >= 70 && score <= 79)
{
std::cout << "The grade is a C.";
}
else if (score >= 80 && score <= 89)
{
std::cout << "The grade is a B.";
}
else if (score >= 90 && score <= 100)
{
std::cout << "The grade is an A.";
}
}
int main()
{
int score;
score = 0;
getScore();
printGrades(int score);
return 0;
}
And these are the error messages I'm getting:
Code:
(45) : error C2144: syntax error : 'void' should be preceded by ')'
(45) : error C2660: 'getScore' : function does not take 0 arguments
45) : error C2059: syntax error : ')'
(46) : error C2144: syntax error : 'int' should be preceded by ')'
(46) : error C2660: 'printGrades' : function does not take 0 arguments
(46) : error C2059: syntax error : ')'
- 6 error(s), 0 warning(s)
Is there a tutorial or something that could explain this to me clearly. I have seen a bunch of them but they always use main and not 2 functions.
Thanks yfor your help.