Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int
- main (void)
- {
- int temp;
- double average;
- int hot_day, pleasant_day, cold_day;
- char x;
- double total;
- double avg;
- hot_day = 0;
- pleasant_day = 0;
- cold_day = 0;
- total = 0.0;
- do
- {
- printf("\nEnter the temperature <-99 to stop>: ");
- scanf("%d", &temp);
- if (temp == -99)
- break;
- if(temp >= 85)
- hot_day++;
- if(temp < 85 && temp >=60)
- pleasant_day++;
- if(temp < 60)
- cold_day++;
- total += temp;
- } while (temp != -99);
- avg = total/(hot_day + pleasant_day + cold_day) ;
- printf("\nThe number of hot days is %d.\n", hot_day);
- printf("The number of pleasant days is %d.\n", pleasant_day);
- printf("The number of cold days is %d.\n", cold_day);
- printf("\nThe average temperature is %.2f\n",avg);
- system ("pause");
- return (0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement