Create a one dimensional integer array large enough to store 10,000 numbers. Fil
ID: 642858 • Letter: C
Question
Create a one dimensional integer array large enough to store 10,000 numbers. Fill the array with random numbers in the range of -100 to +100, inclusive. (25 points)
a. Calculate the sum of all the numbers stored in the array and print it.
b. Calculate the average of the numbers stored in the array and print it.
c. Find the number that occurs most frequently in the array, print the number and how many times it occurs in the array.
d. Find the smallest number stored in the array and print it.
Matrix math operations (25 points)
a. Write a C program that creates two square matrices, 5 rows by 5 columns. Fill them with random numbers in the range -9 to +12 (inclusive).
b. Add the two matrices and store the result in a third matrix. Display the resulting matrix.
c. Subtract one matrix from the other and display the results.
d. Multiply two matrices and display the resulting matrix.
Explanation / Answer
a)
creates a sparse (n+1)-by-(n+1) sparse matrix with a single diagonal defined.
Function File: [b, c] = spdiags (A)
Function File: b = spdiags (A, c)
Function File: b = spdiags (v, c, A)
Function File: b = spdiags (v, c, m, n)
d)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.