PLEASE REPLY ASAP
To determine the mode, you need to create a new array
called count so that count keeps track of
the number of times that the score i has appeared. Since
we will assume that the scores are between 0 and 20 (inclusive), it
is good to define a constant for this value:
To complete the program, you need to do the following:
Declare a new count[] array.
Initialize each element of count[] to 0.
Iterate through the elements of the A[] array and
update count[] in each iteration.
(a) The array A[] holds the scores.
(b) For example, when your program sees that A[34] = 11, you
should add 1 to count[11],
indicating another observation of that score.
Iterate through the count[] array and print out the
number of times that each score appeared.
Iterate through the elements of the count[] array to
find the maximum count and the score with the maximum count (the
mode).
Print out the score that has the highest count and the number of
times that score appeared
use this starter code: PROGRAM IN C
int main() { inti=0; intn=0;
return 0; }
if u can do extra credit:
Count how many invalid scores there are in the input file. Do
this by adding a check for invalid scores in the loop you wrote for
Step 3. Then, after printing the mode, print how many invalid
scores there were, if any.
PLEASE REPLY ASAP To determine the mode, you need to create a new array called count so that count[i] keeps track of the
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am