ok this is the code i have gotten so far and it still doesnt work. it says:
Line (5) : error C2146: syntax error : missing ';' before identifier 'calls'
Line (5) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Line (5) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Line (34) : error C2065: 'average' : undeclared identifier
Line (35) : error C2109: subscript requires array or pointer type
Line (39) : error C2146: syntax error : missing ';' before identifier 'calls'
Line (39) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Line (39) : error C2086: 'int Values' : redefinition
Line (5) : see declaration of 'Values'
Line (40) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Line (41) : error C2065: 'size' : undeclared identifier
Line (57) : error C2146: syntax error : missing ';' before identifier 'v'
Line (57) : error C2065: 'v' : undeclared identifier
Line (58) : error C2228: left of '.max' must have class/struct/union type is ''unknown-type''
Line (59) : error C2228: left of '.min' must have class/struct/union type is ''unknown-type''
Line (60) : error C2228: left of '.avg' must have class/struct/union type is ''unknown-type''
Line (62) : error C2143: syntax error : missing ';' before 'return'
This is the code I have.
CODE
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
Values calls(float*,float, float, float);
int main()
{
float arr[100]={0};
class Values
{
public:
float max;
float min;
float avg;
};
float *ptra, a;
ptra=arr;
int j, i=1;
do
{
cout<<"Enter grade (-1 to end): " << endl;
cin >> arr[i];
i++;
} while (arr[i-1] > 0);
cout << "Number" <<" " <<"Grade"<<endl;
cout << "------" <<" " <<"------"<<endl;
for (j=1;(j<i)&& (arr[j] >=0);j++)
cout<<j<<" "<<arr[j]<<endl;
int size=sizeof(arr);
a=calls(ptra,max,min,average);
cout << "max is :" << a[0]<< endl;
return 0;
}
Values calls(float *ptra, float max, float min, float avg)
{
for (int j=1; j = size;j++)
{
if (*ptra > *ptra+1)
{
max=*ptra;
min=*ptra+1;
j++;
}
else if (*ptra < *ptra+1)
{
max=*ptra+1;
min=*ptra;
j++;
}
avg=*ptra/j;
}
Values v;
v.max = max;
v.min = min;
v.avg = avg
return v;
}