Question: a. Write a program in C code to process a collection of daily high temperatures. Your program should count and print the number of hot
a. Write a program in C code to process a collection of daily high temperatures. Your program should count and print the number of hot days (high temperature 26 degrees or higher, the number of pleasant days (high temperature 12-25), and the number of cold days (high temperatures less than 12). It should also display the category of each temperature. Test your program on the following data: 12 17 19 22 13 8 6 14 15 2 28 23 25 4 6 24 15 16 21 30 26 5 0 7 11 14 b. Modify your program to accept input data from the attached text file (temps.txt) and output the results to a text file.
Here is my code for part a, i would have the text file on my computer, it esentially contains the same inputs as part a i just need to figure out how to point to it and export the output as a text file.
#define _CRT_SECURE_NO_WARNINGS
#include
int main(void)
{
double x, h, m, c;
h = 0;
c = 0;
m = 0;
x = 0;
while (x != 1000)
{
printf("Please enter a temperature Enter 1000 to exit ");
scanf(" %lf", &x);
if (x >= 26)
{
h++;
printf("%.2f is a hot day ", x);
}
else if (x < 26, x >= 12)
{
m++;
printf("%.2f is a mild day ", x);
}
else if(x<12)
{
c++;
printf("%.2f is a cold day ", x);
}
printf("warm days:%.2f Mild days:%.2f Cold days:%.2f ", h, m, c);
}
return(0);
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
