Answer:
#include <stdio.h>
int main()
{
//variable declaration
int low, high;
float lowRain, highRain, total, avg;
//array declaration
float rainfall[13];
char monthName[13][10] = {"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
//get user input
for(int i=1; i<=12; i++)
{
printf("Enter the rainfall (in inches) for %s: ", monthName[i]);
scanf("%f", &rainfall[i]);
}
//display the monthly rainfall
printf("\nThe rainfall that was entered was:\n");
for(int i = 1; i<=6; i++)
printf("%s ", monthName[i]);
printf("\n");
for(int i = 1; i<=6; i++)
printf("%.1f ", rainfall[i]);
printf("\n");
for(int i = 7; i<=12; i++)
printf("%s ", monthName[i]);
printf("\n");
for(int i = 7; i<=12; i++)
printf("%.1f ", rainfall[i]);
//variable initialization
low = 1;
high = 1;
lowRain = rainfall[1];
highRain = rainfall[1];
total = 0;
//calculate the lowest, highest and averaage rainfall
for(int i=1; i<=12; i++)
{
if(lowRain>rainfall[i])
{
lowRain = rainfall[i];
low = i;
}
if(highRain<rainfall[i])
{
highRain = rainfall[i];
high = i;
}
total = total + rainfall[i];
}
avg = total / 12;
//display the result
printf("\n\nThe total rain that fell was %.1f inches", total);
printf("\nThe average monthly rainfall was %.1f inches.", avg);
printf("\nThe lowest monthly rainfall was %.1f inches in %s.", rainfall[low], monthName[low]);
printf("\nThe highest monthly rainfall was %.1f inches in %s.", rainfall[high], monthName[high]);
return 0;
}