Advertisement
Guest User

C

a guest
Nov 5th, 2012
387
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.83 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main(){
  4.     FILE *input, *output;
  5.     float maxtemp=0, mintemp = 0, maxwind_speed=0, minwind_speed=0, maxwind_chill, minwind_chill, temp, wind_dir, wind_speed, wind_chill;
  6.     int reals=0, counter=0;
  7.  
  8.     input = fopen("input.txt","r"); //assigning file to a variable
  9.     while(fscanf(input,"%f %f %f %f \n", &temp, &wind_dir, &wind_speed, &wind_chill) != EOF){ //the loop will continue untill it will be the End Of File
  10.         reals += 4;
  11.         counter += 1;
  12.         maxtemp = max(maxtemp, temp);
  13.         printf("%f %f\n", maxtemp);
  14.     }
  15.  
  16.     fclose(input);
  17.     printf("There are %i succesfuly read real numbers.\n", reals);
  18.     printf("Max. temperature: %2.1f C\nMin. temperature: %2.1f C\n", maxtemp, mintemp);
  19.  
  20.     return 0;
  21. }
  22.  
  23. max(x, y){
  24.     if (x < y){
  25.        x = y;
  26.     }
  27.     return x;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement