CS 2073 Engineering Programming
|
You should also review your work for the programming assignments:
// initialize array named primes to the first 7 primes
int primes[] = {2, 3, 5, 7, 11, 13, 17};
Question: Use a for loop to add up the squares of the primes
stored in the array in 2 above. Print the sum.
Solution.
(Don't access until you've tried the problem.)
int a[25]; int i; for (i = 0; i < 25; i++) a[i] = 0;
Question: Here is a practice problem:
Problem involving arrays.
Solution.
(Don't access until you've tried the problem.)
int a[] = {12, 34, 21, 47, 52, 7, 41};
int asize = 7;
Pass this array and its size to a function maxmin that will calculate both the maximum and the minimum value in the array. The function should have two formal parameters max and min, each of type int *, that is, a pointer to an integer, or the address of an integer. Use these parameters to get the maximum and minimum values back to the function main, where they should be printed. (You must pass the addresses of two ordinary integers as the actual parameters.)