#include <iostream>

using namespace std;


// This program takes the numerical score and outputs a letter grade.//

int getScore ()
{


    int count; 
    int score,



        for (count = 0; count <10; count ++){
    cout << "\nEnter the student's score: "<< endl;
    cin >> score



    }


    cout <<"\nThe score is/are: " << score << endl;
    return 0 ;
}



int printGrade()

{


    int grade =0;   


    if ( grade >= 90)
        cout <<"\nYour grade is A." << endl;
    else
    if (grade >= 80 )
        cout <<"\nYour grade is B." << endl;
    else
    if (grade >= 70 )
        cout <<"\nYour grade is C." << endl;
    else
    if (grade >= 60 )
        cout <<"\nYour grade is D." << endl;
    else
        cout <<"\nYour grade is F." << endl;    




return 0;

}

int main ()
{

    getScore();
    printGrade();
    int num = getScore ();

    cout << printGrade(num);



 return 0;
}

Dani AI

Generated

Quick diagnosis for 's thread: the compiler error C2660 (reported at line 68) is a symptom, not the full story. The code shows a handful of small syntax typos (missing semicolons, stray commas) plus mismatched function signatures and return/usage conventions. correctly pointed out missing semicolons, explained how parameters work, and demonstrated a working layout — the bullets below turn those observations into a compact repair and hardening checklist.

  • Fix the obvious syntax first: change stray commas in declarations to semicolons, add the missing semicolons after statements like cin >> score;, and make sure every opening brace/parenthesis has a matching closer. Start at the first compiler error; later messages usually cascade.
  • Make getScore do one thing: read a single integer, validate it, and return that integer (do not return 0 unconditionally). Alternatively, make it void and provide the value via an out parameter — but keep intent consistent.
  • Make printGrade accept an int parameter (for example printGrade(int grade)) and, if it only prints, declare it void. Remove any local grade that hides the passed-in value.
  • In main call getScore() once per student inside the loop and pass the returned value to printGrade. Avoid constructs like cout << printGrade(num) when printGrade prints directly or returns nothing useful.
  • Add input checks: verify cin >> score succeeded and that score is within an expected range (e.g., 0–100). On bad input clear cin and discard the token before retrying.
  • Turn on compiler warnings (/W4 or /Wall on MSVC, -Wall -Wextra on g++) — they catch many of these mistakes early.

Extra notes: declare prototypes or place helper functions above main to clarify compile order. Prefer focused functions (read, compute, print) and, when collecting multiple scores, store them in a small container if later processing is needed. Following the checklist resolves C2660 and makes the program far easier to maintain.

Recommended Answers

All 7 Replies

what errors are you getting? I see a couple of missing semicolons -- your compiler should complain about them. Look at the errors, then look at your code and see if you can figure out what's wrong.

This is the error i'm getting


Compiling...
printGrade.cpp
C:\Documents and Settings\Administrator\My Documents\printGrade.cpp(68) : error C2660: 'printGrade' : function does not take 1 parameters
Error executing cl.exe.

printGrade.obj - 1 error(s), 0 warning(s)

That error means the program is attempting to pass the wrong number of parameters. how many parameters to you see in that function? It doesn't have any parameters, yet your program is attempting to pass one parameter -- they have to be consistent.

i dont understand

i dont understand

Read your own program. That function has no parameters.

You better read about local variables, glodabl variables, and passing arguments to functions.

Here is a corrected version.

#include <iostream>
using namespace std;
// This program takes the numerical score and outputs a letter grade.//
int getScore ()
{
[INDENT]int count;
int score,

cout << "\nEnter the student's score: "<< endl;
cin >> score
cout <<"\nThe score is/are: " << score << endl;
return score;[/INDENT]
}



int printGrade( int grade)
{
[INDENT]if ( grade >= 90)
[INDENT]cout <<"\nYour grade is A." << endl;[/INDENT]
else if (grade >= 80 )[INDENT]cout <<"\nYour grade is B." << endl;[/INDENT]else if (grade >= 70 )[INDENT]cout <<"\nYour grade is C." << endl;[/INDENT]else if (grade >= 60 )[INDENT]cout <<"\nYour grade is D." << endl;[/INDENT]else[INDENT]cout <<"\nYour grade is F." << endl;[/INDENT]return 0;[/INDENT]}

int main ()
{
[INDENT]for ( int i = 0 ; i < 10 ; i++ )
{
[INDENT]int num = getScore ();
printGrade(num);[/INDENT]
}
return 0;[/INDENT]
}

i dont understand

Do you know what 'pass a parameter' means?

//If you have this function...
int printGrade(int grade) {
  if ( grade >= 90) {
     ...
  }
}

// 'grade' is a parameter that is passed into the function.

int main () {
  ...
  printGrade(23);
  ...
}

// Here the value 23 is passed into the function 'printGrade'
// using the variable 'grade'
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.