Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program that does the following in C. 1. Reads 10 temperatures from the

ID: 3907523 • Letter: W

Question

Write a program that does the following in C.

1. Reads 10 temperatures from the console (standard input). Each value represents the high temp for a given day in a 10-day period.

2. Stores the temperatures in an array. You must use the same array for all the temperatures.

3. Finds and displays the highest recorded temperature.

4. Finds and displays the day when the highest temperature was recorded. If two or more days tie for the highest temperature, the program will report all the days with the highest temperature.

Hint: To save time, create a text file with test data and use input redirection when testing your code.

Sample:

You will be asked to enter the daily high temperature for 10 consecutive days. Enter a high temperature: 91 Enter a high temperature: 93 Enter a high temperature: 92 Enter a high temperature: 97 Enter a high temperature: 90 Enter a high temperature: 88 Enter a high temperature: 95 Enter a high temperature: 97 Enter a high temperature: 96 Enter a high temperature: 96

The highest recorded temperature in the 10-day period was: 97 degrees Recorded on the following days: Day 4 Day 8

Explanation / Answer

Program

#include<stdio.h>
void main()
{
    int temp[10],i,high;
    printf("You will be asked to enter the daily high temperature for 10 consecutive days. ");
    for(i=0;i<10;i++)
    {
        printf(" Enter a high temperature: ");
        scanf("%d",&temp[i]);
    }
    high=temp[0];
    for(i=1;i<10;i++)
    {
        if(temp[i]>high)
        {
        high=temp[i];
        }
    }
    printf(" The highest recorded temperature in the 10-day period was: %d degrees",high);
    printf(" Recorded on the following days: ");
    for(i=0;i<10;i++)
    {
        if(temp[i]==high)
            printf(" Day %d ",i+1);

    }

}

Output

You will be asked to enter the daily high temperature for 10 consecutive days.

Enter a high temperature: 91

Enter a high temperature: 93

Enter a high temperature: 92

Enter a high temperature: 97

Enter a high temperature: 90

Enter a high temperature: 88

Enter a high temperature: 95

Enter a high temperature: 97

Enter a high temperature: 96

Enter a high temperature: 96

The highest recorded temperature in the 10-day period was: 97 degrees

Recorded on the following days: Day 4 Day 8

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote