C+P code use to work but now it doesn't!
Code:
#include"stdafx.h"
#define SIZE 10
#define LENGTH 10
#defineFormatLength 4
void ReadScore(float *, int); //by ref, by value
void ReadMin(float *); //by ref, by name
float ComputeAvg(float *, int); //by ref, by value
float FindHighestScore(float *, int);
float FindLowestScore(float *, int);
int FindNum(float *, int, float); //by ref, by value, by value
void Print(float *, int); //by ref, by value
void PrintResults(int, float, float, float, int, int); //by value
//ofstream f_cout("Project1_PartA.txt", ios::out);
int main()
{
// Storage
float Exam, avg, highest, lowest, Min_Pass, Min[5];
int Num_Pass, Num_A;
// INPUT
ReadScore(Exam, SIZE);
//by ref, by value
ReadMin(Min);
//by ref, by name
// Process
avg = ComputeAvg(Exam, SIZE);
//by ref, by value
FindHighestScore(Exam, SIZE);
FindLowestScore(Exam, SIZE);
Num_Pass = FindNum(Exam, SIZE, Min[5]);
//by ref, by value, by value
Num_A = FindNum(Exam, SIZE, Min[5]);
//OUTPUT
Print(Exam, SIZE);
//by ref, by value
PrintResults(SIZE, avg, highest, lowest, Num_Pass, Num_A);
//by value
return 0;
}
//INPUT
void ReadScore(float *Ex, int n) //by ref, by value
{
int i;
for (i = 0; i < n; i++)
{
cout << "Enter grades: ";
cin >> Ex[i];
}
}
void ReadMin(float *min) //by ref, by name
{
cout << endl << endl;
cout <<
"Enter the minimum score for an A, B, C, D, and passing: " << endl;
for (int i = 0; i < 5; i++)
{
cin >> min[i];
}
}
//Process
float ComputeAvg(float *Ex, int n) //by ref, by value
{
int i;
float sum = 0;
for (i = 0; i < n; i++)
{
sum = sum + Ex[i];
}
return (sum / n);
}
int FindNum(float *Ex, int n, float Min_P) // by ref , by value, by name
{
int i, count = 0;
for (i = 0; i < n; i++)
{
if (Ex[i] >= Min_P)
count++;
}
return count;
}
€€
// OUTPUT
void Print(float *Ex, int n) //by ref, by value
{
int i;
for (i = 0; i < n; i++)
{
if (i % LENGTH == 0)
cout << endl;
cout << setw(FormatLength) << Ex[i];
}
}
void PrintResults(int n, float av, float high, float low, int Num_P, int Num_A) // value
{
cout << '\n' << "Average Score is: " << av << endl;
cout << "Highest is: " << high << endl;
cout << "Lowest is: " << low << endl;
cout << "Number Passed is: " << Num_P << endl;
cout << "Number Failed is: " << n - Num_P << endl;
cout << "Number with a A: " << Num_A << endl;
}
float FindHighestScore(float *Ex, int n)
{
float high = Ex[0];
for (int i = 1; i < n; i++)
{
if (high < Ex[i])
high = Ex[i];
}
return high;
}
€€float FindLowestScore(float *Ex, int n)
{
float low = Ex[0];
for (int i = 1; i < n; i++)
{
if (low > Ex[i])
low = Ex[i];
}
return low;
}
The problem is the FindHighestScore and FindLowestScore functions keep telling me that the variables "highest" and "lowest" are uninitialized but they were before when I tested it. By initializing them to 0, I get "Highest = 0" and "Lowest = 0".
What's wrong with it?