Hello,

Working on a project for school and I am stuck. It is a program to calculate windchill and although I have it working, I need to call outside of the main program to calculate the mean and min_max values, which I have both in the main. Calling outside of the main is my weak-point for sure, and really need help help here. Don't mind the location of my declarations and stuff I will clean that up after I got this working how it should, haha.

Basically, we need to use function prototypes:

1.) double mean(double[], int)

2.) void min_max(double [], int)

And this is my program:

Code:

#include <stdio.h>
#include <math.h>
#define INFO "data_5a_08.txt"
#define N 10
void info (void);
int main ()
{
//declarations
info ();
int T[N], V[N];
double windchill[N], mean=0, sum =0, max = 0, min = 0;
int k = 0;
//file open
FILE*data;
data = fopen(INFO, "r");
if (data == NULL)
printf("Error opening file\n\n");
else
{
printf("Temp (F): Wind Speed (mph): Wind Chill:\n");
for (int k=0; k<=N-1; k++)
{
while((fscanf(data,"%i %i", &T[k], &V[k])) == 1);
windchill[k] = 35.74 + 0.6215*T[k] - 35.75*pow(V[k],0.16)+ 0.4275*T[k]*pow(V[k],0.16);
printf("%3i \t\t %3i \t\t %13.1lf\n", T[k], V[k], windchill[k]);
}
//mean
for (int z=0; z<=N-1; z++)
{
sum = sum + windchill[z];
mean = sum;
}
printf("\n\nAverage Windchill:%5.1f\n\n", mean/N);
//min and max chills
for (int y=0; y<=N-1; y++)
{
if(windchill[y]>max)
max= windchill[y];
else if (windchill[y]<min)
min= windchill[y];
}
printf("Max Windchill:%5.1f\n\n", max);
printf("Min Windchill:%5.1f\n\n", min);
fclose(data);
}
return 0;
}