Question: InC language using arrays and printf / scanf. I've done most of the work, I just don't know how to do the rest. Heres what
InC language using arrays and printf / scanf.
I've done most of the work, I just don't know how to do the rest.
Heres what I have so far:
#define _CRT_SECURE_NO_WARNINGS // Disable warnings (and errors) when using non-secure versions of printf, scanf, strcpy, etc.
#include
#include
int main(void)
{
// Constant and Variable Declarations
const int NUM_MONTHS = 12;
double rainFall[NUM_MONTHS];
char monthAbbr[NUM_MONTHS][4];
int i = 0;
// Parallel Arrays
strcpy(monthAbbr[i], "Jan"); rainFall[i] = 0; i++;
strcpy(monthAbbr[i], "Feb"); rainFall[i] = 0; i++;
strcpy(monthAbbr[i], "Mar"); rainFall[i] = 0; i++;
strcpy(monthAbbr[i], "Apr"); rainFall[i] = 0; i++;
strcpy(monthAbbr[i], "May"); rainFall[i] = 0; i++;
strcpy(monthAbbr[i], "Jun"); rainFall[i] = 0; i++;
strcpy(monthAbbr[i], "Jul"); rainFall[i] = 0; i++;
strcpy(monthAbbr[i], "Aug"); rainFall[i] = 0; i++;
strcpy(monthAbbr[i], "Sep"); rainFall[i] = 0; i++;
strcpy(monthAbbr[i], "Oct"); rainFall[i] = 0; i++;
strcpy(monthAbbr[i], "Nov"); rainFall[i] = 0; i++;
strcpy(monthAbbr[i], "Dec"); rainFall[i] = 0; i++;
// *** Your program goes here ***
for (i = 0; i
printf("Enter the rainfall (in inches) for %s: ", monthAbbr[i]);
scanf("%lf", &rainFall[i]);
}
return 0;
} // end main()

Chapter 5-Arrays-702 C Secure https://bb tctc.edu/webapps/blackboard/content/listContentsp?course id-481118-1&content_id:5580341 ASSIGNMENT Write a program to display the total rainfall for a year. In addition, display the average monthly rainfall, and the months with the lowest and highest rainfall. Create an array to hold the rainfall values. Use a constant for the size of the array. Create a 2nd parallel array (as a constant) to hold the abbreviated names of the months. I created my arrays to be 1 element bigger than needed, and then disregarded element [0] (so that my months went from [1 "Jan. to [11: Dec) Populate the array with the rainfall values entered by the user. Then, display the rainfall values. Display the 1st 6 months, followed by the last 6 months Then display the statistics (the total, average, lowest, and highest rainfall) Calculate the total rainfal. After you get the total, you should be able to calculate the average (use the SIZE (minus 1 if the array was 1 element bigger than needed) of the array). Then find the index of lowest rainfall and the index of highest rainfall. Finally, display the statistics, using the indexes that were found to get the lowest and highest rainfall value and the name of the month from the arrays. Format the output to 1 decimal place. There is no validation Example Run #1 bold type is what is entered by the user) Enter the rainfall 1n inchea) for Jan: 1.2 Enter the rainfall 1n inchea) for Feb: 1.5 Enter the rainfall 1n inchea) for Mar: 2.5 Enter the rainfall (in inche a) f Apr : 5.4 Enter the rainfall (in inche a) f May: 3.3 Enter the rainfall 1n inche) for Jun: 0.8 Enter the rainfall 1n inchea) for Jul: 0.9 Enter the rainfall (in inche a) f Aug : 1.3 Enter the rainfall (in inche a) f sep : 2.8 Enter the rainfall 1n inchea) for Oct: 3.4 Enter the rainfall 1n inchea) for Nov: 2.4 Enter the rainfall 1n inchea) for Dec: 1.6 The rainfali that waa entered wa: Feb 1.5 Mar May Tun 1.2 2.5 5.4 Jul 0.9 Nov 2.4 Aug Eep Dec The total rain that fell wa xx.x 1nches The average monthly rainfall was x. x inches Che lowest monthly rainfall was x.x inches in xxx Che highest monthly rainfall Was x.x inches in Xxx The example runs show EXACTLY how your program input and output will look EPIC 6:52 PM 3/11/2018
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
