Question: COP 3223 C Programming Assignment 3 Arrays This assignment is designed in small progressive parts, with the intention of developing the skill of working with

COP 3223 C Programming Assignment 3 Arrays

This assignment is designed in small progressive parts, with the intention of developing the skill of working with arrays. Do each part separately. Include in your submission the code and output for Part I, then the code and output for Part 2, etc. into a Word document.

Specification:

Part 1.

Write a main function that declares an array of 10 ints. Assign each element in the array a value between 1 and 100 using 10 assignment statements just make up the values.

Write a for loop that will printout each of the elements in the array.

Part 2.

Start from scratch on each of the parts.

Write a main function that declares an array of 100 doubles.

In a for loop, assign each of the doubles a random number between 0.50 and 50.00. Heres how.

array[i] = (double) (rand() % 100 + 1) / 2.0;

Output the elements of the array in 10 columns that are each 6 spaces wide.

Each row in the output will have 10 values. The doubles will be printed with 2 places of accuracy past the decimal.

The output of this one-dimensional array requires a single loop with an if statement inside. Even though the 100 numbers are going to be presented as a table of numbers, they are still just a list in memory.

Part 3

Write a main function that declares an array of 100 ints. Fill the array with random values between 1 and 100.

Calculate the average of the values in the array. Output the average.

Part 4

In a main function declare an array of 1000 ints.

Fill up the array with random numbers that represent the rolls of a die. That means values from 1 to 6.

Write a loop that will count how many times each of the values appears in the array of 1000 die rolls.

Use an array of 6 elements to keep track of the counts, as opposed to 6 individual variables.

(continued)

Print out how many times each value appears in the array.

1 occurs XXX times

2 occurs XXX times

Hint: If you find yourself repeating the same line of code you need to use a loop. If you declare several variables that are almost the same, maybe you need to use an array. count1, count2, count3, count4, is wrong. Make an array and use the elements of the array as counters. Output the results using a loop with one printf statement. This gets more important when we are rolling 2 dice.

Deliverables: Submit the following materials:

This assignment with the C programs, neatly styled and documented with comments, and meeting the specifications as described above.

Each program will be followed immediately by the output from running the program.

Put your results into a Word document and submit to webcoures.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!