Programming with Parallel Arrays exercises
Given the following declarations:
#define kMax 100 /* maximum
number of students
*/
int Passing[kMax+1];
/* who passed */
int Score[kMax+1]; /* their scores
*/
int grade;
Assume elements 1 to 100 of array Score contain scores for
100 students.
- Write a code segment that initializes all students in Passing
to
false (zero).
- Write a code segment that sets the students in Passing
to true
(one) wherever
the parallel value of Score is greater than 60.
- Write a code segment that prints the index of the of items
in Passing
that are true (one).
- Write a function that is passed Passing as a parameter
and returns the count of the number of items in Passing
that are true (one).
- Write a function that is passed Score and grade
as parameters and returns
the count of the number of items in Score that are greater
than grade.
- Turn the code segment in problem 2 into a function that is
passed
the two arrays and an integer criterion value.