C Post Lab08
C Post Lab08
Post-Lab #8 Exercises
Student Name
Student University ID
Date
Exercise #1
10 17 12
15 13 11
14 9 16
o Compute and print the sum of each row and each column.
o Compute and print the sum of the main and secondary diagonals’ elements.
o Swap the elements of the main and secondary diagonals.
o Pass the square array to a function named magic, which checks and returns a result to
indicate that the passed square is a magic square or not. A Magic Square is the square in
which the sum of all its rows, columns, and diagonals (Main and secondary diagonals) is the
same.
o Pass the square array to a function named countEven, which counts and returns the
number of even numbers in the array.
o Pass the square array to a function named searchPrime, which searches for and returns
the first prime number in the array. If the array doesn’t contain a prime number, it
returns 0. The main function prints the result.
o Reprint the square array in a tabular format.
o Create a 1-D 3-elements array named diagonal.
o Fill diagonal array with the elements in the diagonal of the square array.
o Pass diagonal array to a function named sort, which sorts the array elements in
descending order.