Advertisement
conception

prog 4

Feb 13th, 2015
280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. #include <stdio.h>
  2. int
  3. main (void)
  4. {
  5. int temp;
  6. double average;
  7. int hot_day, pleasant_day, cold_day;
  8. char x;
  9. double total;
  10. double avg;
  11.  
  12. hot_day = 0;
  13. pleasant_day = 0;
  14. cold_day = 0;
  15. total = 0.0;
  16.  
  17. do
  18. {
  19. printf("\nEnter the temperature <-99 to stop>: ");
  20. scanf("%d", &temp);
  21.  
  22. if (temp == -99)
  23. break;
  24.  
  25. if(temp >= 85)
  26. hot_day++;
  27.  
  28. if(temp < 85 && temp >=60)
  29. pleasant_day++;
  30.  
  31. if(temp < 60)
  32. cold_day++;
  33. total += temp;
  34.  
  35. } while (temp != -99);
  36.  
  37. avg = total/(hot_day + pleasant_day + cold_day) ;
  38.  
  39. printf("\nThe number of hot days is %d.\n", hot_day);
  40. printf("The number of pleasant days is %d.\n", pleasant_day);
  41. printf("The number of cold days is %d.\n", cold_day);
  42.  
  43.  
  44. printf("\nThe average temperature is %.2f\n",avg);
  45. system ("pause");
  46. return (0);
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement