Question
C Programming Assignment 11 2-D Arrays Due Wednesday, April 19, 2017 For each of the programs assigned below, submit the following a hard copy of
C Programming Assignment 11
2-D Arrays
Due Wednesday, April 19, 2017
For each of the programs assigned below, submit the following a hard copy of the source code (.c file) on Canvas under Assignment 11.
Observe the usual guidelines regarding the initial comment section, indenting, and so on. In addition, when functions are required, place function definitions following main. At the beginning of the program and before each function use comments to explain what the function does. Do not use global variables.
1. The Pascal triangle can be used to compute the coefficients of the terms in the expansion of (a+b)n. In a Pascal triangle, each element is the sum of the element directly above it and the element to the left of the element directly above it (if any).
An example of a triangle of size 7 is shown below:
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
1 5 10 10 5 1
1 6 15 20 15 6 1
Declare a two-dimensional array in function main (allow the array to contain up to 25 rows and 25 columns) and initialize elements to 0. Have the user input the size of the Pascal triangle (up to 25).
Write a function to compute the coefficients of the Pascal triangle. Call the function to calculate values for the triangle for the given size. Function parameters should be the array and the size of the triangle. Print the triangle from function main (do not print the elements that have been initialized to 0 but are not part of the triangle).
Hint: Note that triangle[0][0], triangle[1][0], triangle[1][1] as well as all other values in column 0 are equal to 1.
2. Yearly rainfall data for four weather stations in a certain county is recorded in the table below.
County Rainfall in Inches
Station | 2005 | 2006 | 2007 | 2008 | 2009 | 2010 |
1 | 39.4 | 45.6 | 42.3 | 44.7 | 37.3 | 41.6 |
2 | 41.0 | 47.2 | 43.8 | 42.0 | 36.9 | 38.2 |
3 | 38.1 | 47.9 | 42.9 | 43.6 | 36.2 | 42.8 |
4 | 41.8 | 46.5 | 44.1 | 45.0 | 38.1 | 43.3 |
Initialize at declaration a double subscripted array of doubles with the rainfall data at the four stations for the six years shown. It may also be convenient to initialize an array of years and an array of station numbers.
Call a function to find the average rainfall for each year. Function parameters will include the two-dimensional array of rainfall data and the one-dimensional array of yearly averages. The number of rows and columns in the array may be defined as symbolic constants or may be passed as array parameters.
Call a second function to find the average rainfall in the county for the 6-year period. Return the overall average pass by value. The array of rainfall data will be a function parameter. The number of rows and columns in the array may be defined as symbolic constants or may be passed as array parameters.
Call a third function to print the labeled table of rainfall data, the yearly averages, and the overall average. Print the yearly averages directly below the column data for the appropriate year. Determine with an if statement the years in which the rainfall was above the overall average; then print.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started