I tried to make a calculator for midterm and final grades of 5 students. 40% of Midterm and 60% of finals in an array a[5][3]. a[5][3] because 5 students, 3 lines because 1 for midterm another for finals and last one for overall grade(40% of Mid. + 60% of Finals). I get the "error lnk2019". What is wrong with that code? Thanks..
#include "stdafx.h"
#include <iostream>
using namespace std;
float a[5][3];
float data(float x);
float calc(float y);
float HL(float z);
int main()
{
data(a[5][3]);
calc(a[5][3]);
HL(a[5][3]);
system("pause");
return 0;
}
float data(float x[5][3])
{
for (int i = 0; i < 5; i++)//Getting the Grades
{
cout << "Enter midterm for St" << i + 1 << " : ";
cin >> x[i][0];
cout << "Enter final for St" << i + 1 << " : ";
cin >> x[i][1];
}
return x[5][3];
}
float calc(float y[5][3])
{
for (int i = 0; i < 5; i++)//Calc. Overall Grades
{
y[i][2] = y[i][0] * 0,4 + y[i][1] * 0,6;
}
return y[5][3];
}
float HL(float z[5][3])
{
float max = 0, min = 0;
for (int i = 0; i < 5; i++)//Finding Highest and Lowest
{
if (z[i][2]>max)
{
max = z[i][2];
}
if (z[i][2] < min)
{
min = z[i][2];
}
}
cout << "The Lowest Grade : " << min << "\nThe Highest Grade : " << max;
return z[5][3];
}
I suggest you go through a tutorial to brush up on your array basics. http://www.cplusplus.com/doc/tutorial/arrays/
You syntax for calling the functions is incorrect. Also, your functions prototypes do not match.
and
Also, when calling the function, don't specify the dimensions.