- #1
ozgurakkas
- 15
- 0
I have made this program, and everything seems to be fine, except one error which says
"Declaration syntax error" in CPP 6, which is "int low (int [])" I keep getting the same error. Anyone can help me with this?
#include <stdio.h>
#define NUM 5
void fillarray( int []);
double mean1(int []);
int high(int []);
int low(int []);
void main()
{
int scores [NUM];
fillarray (scores);
printf("The class average is %1.2f\n", mean1(scores));
printf("The highest score is %d\n", high(scores));
printf("The lowest score is %d\n", low(scores));
}
void fillarray (int scores [])
{
int x;
for (x=0;x<NUM;x++)
{
printf("Enter the score number %d\n", x+1);
scanf("%d", &scores[x]);
}
}
double mean1(int scores[])
{
int x, sum=0;
double m;
for (x=0;x<NUM;x++)
sum=sum + scores[x];
m=(double)sum/NUM;
return m;
}
int high(int scores[])
{
int x, h= scores[0];
for (x=1;x<NUM;x++)
if (h<scores[x])
h=scores[x];
return h;
}
int low(int scores[])
{
int x, l=scores [0];
for (x=l;x<NUM;x++)
if (l>scores[x])
l= scores[x];
return l;
}
"Declaration syntax error" in CPP 6, which is "int low (int [])" I keep getting the same error. Anyone can help me with this?
#include <stdio.h>
#define NUM 5
void fillarray( int []);
double mean1(int []);
int high(int []);
int low(int []);
void main()
{
int scores [NUM];
fillarray (scores);
printf("The class average is %1.2f\n", mean1(scores));
printf("The highest score is %d\n", high(scores));
printf("The lowest score is %d\n", low(scores));
}
void fillarray (int scores [])
{
int x;
for (x=0;x<NUM;x++)
{
printf("Enter the score number %d\n", x+1);
scanf("%d", &scores[x]);
}
}
double mean1(int scores[])
{
int x, sum=0;
double m;
for (x=0;x<NUM;x++)
sum=sum + scores[x];
m=(double)sum/NUM;
return m;
}
int high(int scores[])
{
int x, h= scores[0];
for (x=1;x<NUM;x++)
if (h<scores[x])
h=scores[x];
return h;
}
int low(int scores[])
{
int x, l=scores [0];
for (x=l;x<NUM;x++)
if (l>scores[x])
l= scores[x];
return l;
}