1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
#include <stdio.h>
#include <stdlib.h>
int hour, temp, average, sum, max, min;
void pro()
{
sum=sum+temp;
average=sum/7;
}
void iffy()
{
if(temp<25)
{
min=temp;
}
if(temp>max)
{
max=temp;
}
}
void time()
{
//for the hours of the max and min temps
}
int main()
{
FILE *fptr;
if((fptr = fopen("temps and hours.txt", "r")) == NULL)
{
perror("Error! opening file");
exit(1);
}
while(EOF != fscanf(fptr, "%d %d", &temp, &hour))
{
printf("%d %d \n", temp, hour);
pro();
iffy();
}
printf("\nThe average temperature is: %d", average);
printf("\nThe minimum temperature is: %d", min);
printf("\nThe maximum temperature is: %d", max);
printf("\nThe time for the maximum and minimum temperature is: %d %d", //not sure);
}
|