954,500 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Function and variable next

// grade.cpp
// display the letter grade corresponding to an exam
// score assuming a noormal scale

# include <iostream>;
using namespace std;

void displayGrade (int score);

 int main ()
{
     int score;
     displayGrade();
     cin.get();
     return 0 ;
     }
// get the data
void displayGrade
cout << " ENTER THE GRADE : " << score << endl;
cin >> score;
{
    if ( score >= 90 ) cout << "grade is A" << endl;
    else if ( score >=80 ) cout << "grade is B " << endl;
    else if ( score >= 70 ) cout << " grade is C " << endl;
    else if ( score >= 60 ) cout << " grade is D " << endl;
    else cout << "grade is F " << endl;
}
return displayGrade;


I am still confused with the function and variable and the way we declare and organize it/.

Se7Olutionyg
Junior Poster
109 posts since Oct 2008
Reputation Points: 3
Solved Threads: 0
 

// grade.cpp // display the letter grade corresponding to an exam // score assuming a noormal scale

# include ; using namespace std;

void displayGrade (int score);

int main () { int score; displayGrade(); cin.get(); return 0 ; } // get the data void displayGrade cout << " ENTER THE GRADE : " << score << endl; cin >> score; { if ( score >= 90 ) cout << "grade is A" << endl; else if ( score >=80 ) cout << "grade is B " << endl; else if ( score >= 70 ) cout << " grade is C " << endl; else if ( score >= 60 ) cout << " grade is D " << endl; else cout << "grade is F " << endl; } return displayGrade;

I am still confused with the function and variable and the way we declare and organize it/.

Hi ,
Your question is not clear to me.. what exactly you want to know.
The code written above will give compilation error as it will not identify any function displayGrade() as the function you have declared before main is displayGrade(int).
Hence before calling any function make sure that the function is atleast declared.
There are also a few syntax errors. But please be specific what exactly you want.

rati
Junior Poster in Training
78 posts since Aug 2006
Reputation Points: 45
Solved Threads: 1
 

Hi

here is your way to a good grade.... :D

// grade.cpp
// display the letter grade corresponding to an exam
// score assuming a noormal scale

# include <iostream>;

void displayGrade (int);

 int main ()
{
    int score;
	std::cout << " Enter your score to get a grade : " << std::endl;
	std::cin >> score;
	displayGrade(score);
	return 0 ;
}
// get the data
void displayGrade(int someScore)
{
	if ( someScore >= 90 ) 
		std::cout << "For this score you get grade A" << std::endl;
    else if ( someScore >=80 ) 
		std::cout << "For this score you get grade B " << std::endl;
    else if ( someScore >= 70 ) 
		std::cout << "For this score you get grade C " << std::endl;
    else if ( someScore >= 60 ) 
		std::cout << "For this score you get grade D " << std::endl;
    else 
		std::cout << "For this score you get grade F " << std::endl;
}


However u aint going to learn , unless u compare it with what u posted before and see your mistakes :cool:

sidatra79
Junior Poster
114 posts since Feb 2008
Reputation Points: 46
Solved Threads: 8
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You