dimanche 6 décembre 2015

nan (not a number?) being placed in the elements the array

Hey guys I'm working on this assignment where I have to calculate the average of the score of 5 judges (stored in array scores[]) in Dev-C++ 5.5.1. The elements i've input in void function getscores (checked by scorecheck) do not seem to be stored in the array scores in main.

entire code is here.

The most I've gotten out of attempting to googling and figuring out what might be the problem would assuming the problem is located in one of the functions.

void getscores(double scores[])
{
double s;
for(i=0;i<size;i++)
{
cout<<"What is the score for Judge #"<<i+1<<" (1 to 10)? \n";
cin>>s;
s=scorecheck(s);
scores[i]=s;        
}
double scorecheck (double k)
{
if(k<1||k>10)
{
do{         
cout<<"Score invalid. Please renter test score \n";
cin>>k;                 
}         
while(k<1||k>10);
return k;
}

I'm assuming that the underlying problem is the way I've written calling the function scorecheck into the function getscore. if that is so, any pointers to the correct way of writing it would be greatly appreciated!

Any positive or negative responses are welcomed.

Aucun commentaire:

Enregistrer un commentaire