i keep getting this error (error C2447: '{' : missing function header (old-style formal list?)
can someone give me a hint or help me out, I went from 23 errors to 1.

// Enter a grade which is 1 and 100 for user.
#include <iostream>
using std::cin; 
using std::cout;
using std::endl;
using std::cerr;

#include <cstdlib>
using std::rand;

#include <ctime>

void grade();

bool isCorrect( int, int ); // function

int main();
{
   // srand( time( 0 ) ); // seed random number generator
   grade(void);

   return 0; // termination

} // end main

// grade generates numbers between 1 and 100
// and checks grade
void grade()
{
   int answer; // randomly generated number
   int guess; // grade entered
   char response; // 'y' or 'n'

   do{
      // generate random number between 1 and 100
      // 1 is shift, 100 is scaling factor
      answer = 1 + rand() % 100;

      // prompt for grade
      cout << "Enter number between 1 and 100.\n" 
           << "Enter Grade?\n" << endl << "? ";
       
      cin >> guess;

      // loop until correct number
      while ( !isCorrect( guess, answer ) ) 
         cin >> guess;      

      // prompt for another grade
      cout << "\nExcellent! The grade is !\n"
           << "Would you like to enter a grade again (y or n)? ";
      cin >> response;

      cout << endl;
   } while ( response == 'y' );
}// end function grade

// isCorrect returns true if g equals a
// if g does not equal a, displays hint
bool isCorrect( int g, int a )
{
   // grade is correct
   if ( g == a )
      return true;

   // grade is incorrect; display hint
   if ( g < a )
      cout << "Grade is to low. Try again.\n? ";
   else
      cout << "Grade is to high. Try again.\n? ";

   return false;
} // end function isCorrect

Recommended Answers

All 3 Replies

You're right. Why bother using code tags.

>> int main();
>> {

Should be

>> int main()
>> {

No ; after main.

still get error,
Now that I have no hair......
is there anything else...

grade(void);

It's just

grade();

Next time, use the code-tags. Between joining the forum and posting your first message there are many opportunities to learn how to do this, and you failed all of them.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.