Your printf/scanf formats are mixed up, and you're using floats as array subscripts.
Also, the indentation could be a lot better.
Code:
#include<stdio.h>
//!!#include<conio.h>
float average(float[], float);
float highest(float[], float);
float lowest(float[], float);
int main(void) //!! fixed
{
float temper[15];
float x, n, y, z;
int day;
//!!clrscr();
printf("enter the no.days to read temperature for=\n");
scanf("%d", &n);
for (day = 0; day < n; day++) {
printf("temperature for day%d=", day + 1);
scanf("%f", &temper[day]);
}
x = average(temper, n);
printf("average temperature is=%.2f\n", x);
y = highest(temper, n);
printf("highest temperature is=%.2f\n", y);
z = lowest(temper, n);
printf("lowest temperature is=%.2f\n", z);
//!!getche();
return 0; //!! added
}
float average(float temper[], float n)
{
int sum = 0.0, x;
float average;
for (x = 0; x < n; n++)
sum += temper[x];
average = sum / n;
return (average);
}
float highest(float temper[], float n)
{
float highest;
int y;
highest = temper[0];
for (y = 0; y < n; y++)
if (highest < temper[y])
highest = temper[y];
return (highest);
}
float lowest(float temper[], float n)
{
float y, lowest = temper[0];
for (y = 0; y < n; y++)
if (lowest > temper[y])
lowest = temper[y];
return (lowest);
}
Here are the errors that need to be fixed
Code:
$ gcc -Wall bar.c
bar.c: In function ‘main’:
bar.c:13: warning: format ‘%d’ expects type ‘int *’, but argument 2 has type ‘float *’
bar.c: In function ‘lowest’:
bar.c:53: error: array subscript is not an integer
bar.c:54: error: array subscript is not an integer