Or atleast thats what I THINK the problem is. Here is the function I am having toubles with.
The idea is that two numbers are entered, and the code should check to see how many numbers in the array are within those two numbers.
The array was sorted from least to highest in a different function. I always end up with the program only returning '1' for the number of students with in the range... which leads me to believe that my logic in the for loops are incorrect.
Any ideas? Attached is the entire program.
void RangeData(int *grades, int numStudents)
int highRange = 0;
int lowRange = 0;
int lowRangeReturn = 0;
int highRangeReturn = 0;
int gradesInRange = 0;
cout<<"\n\nEnter the low value for a grade range look up: ";
cout<<"Enter the high vaule for a grade range look up: ";
for (studentNumber = 0; lowRange == studentNumber; studentNumber++)
if(lowRange == grades[studentNumber])
lowRangeReturn = grades[studentNumber];
}//find low range number
for (studentNumber = 0; highRange == studentNumber; studentNumber++)
if(highRange == grades[studentNumber])
highRangeReturn = grades[studentNumber];
}//find high range number
gradesInRange = (highRangeReturn - lowRangeReturn)+1;
cout<<"\nThere are "<<gradesInRange<<" students within that range."<<endl;
cout<<"\nWould you like to look up another range? (y/n) ";
if(rangeAgain == 'y' || rangeAgain == 'Y')
else if(rangeAgain == 'n' || rangeAgain == 'N')