424,946 Members | 709 Online
Need help? Post your question and get tips & solutions from a community of 424,946 IT Pros & Developers. It's quick & easy.

# finding mode score

P: 5
they give us 10 days to do a program of finding the modes using array. and i dont really know how to do it :(

1.get the number of score of the user
2.allocate array
3.get the scores
4 short scores(array)
5. find the mode ang how may use it.

i hope you can help me.thank you in advance :)
Attached Images
 IMG_20180222_193219.jpg (50.6 KB, 57 views)
Feb 24 '18 #1

Your screen shot says step 5 is to find the middle value in the sorted array. The middle value is the median. The steps for finding the mode are quite different. Which are you being asked to find?

Are you allowed to use the sort function in the standard library or are you expected to write your own?
Which sort algorithms have been discussed in your class?

8 Replies

 Expert Mod 5K+ P: 9,197 Feb 24 '18 #2

 Expert 100+ P: 2,396 Your screen shot says step 5 is to find the middle value in the sorted array. The middle value is the median. The steps for finding the mode are quite different. Which are you being asked to find? Are you allowed to use the sort function in the standard library or are you expected to write your own? Which sort algorithms have been discussed in your class? Feb 27 '18 #3

 P: 5 1.get the number of score of the user 2.allocate array 3.get the scores 4 short scores(array) 5. find the mode ang how may use it. the one on picture is the example they give us but in example they find midian but our asignment is finding the mode Feb 27 '18 #4

 Expert 100+ P: 2,396 You need to count how many students have each score. The score(s) with the most students is(are) the mode. What is the nature of the scores — are they integers or floating-point? Mar 2 '18 #5

 P: 5 it is int ... ................................................ Mar 9 '18 #6

 Expert 100+ P: 2,396 The relevance of integers versus floating-point is thatThere are a finite number of integer scores Integer scores can be reliably compared for equality Mar 10 '18 #7

 Expert 100+ P: 2,396 Suppose the test consists of 200 questions; all questions have the same weight; and there is no partial credit. There are then 201 possible scores — corresponding to how many questions were answered correctly. A brute force approach to finding the mode is to define a 201-element score-tally array; initialize each entry to 0; scan through the list of per-student scores, incrementing the corresponding entry in the tally array; and finally, find the largest entries in the tally array. (I say entries because several scores may be tied for largest tally.) The mode value is the array index of the maximum tally value(s), not the maximum value itself. This is known as a sparse array technique - sparse because many entries in the tally array remain 0. There are other techniques that use less storage but require more complicated code. Mar 10 '18 #8

 P: 5 #include"stdio.h" #include"conio.h" #include"alloc.h" //reads a binarry file then display odds int main (int argc, char *argv[]) { FILE *fp; int *arx , n , i,j, counter; if( argc!=2) { printf("syntax: error:compo < filename.dat>"); return 1; } fp = fopen(argv[1],"rb"); if(!fp) { printf("file not found!"); return 1; } fread(&n,sizeof(int),1,fp); arx= (int*) malloc(n* sizeof(int)); if(!arx) { printf("allocation error!"); return 1; } fread(arx,sizeof(int),n,fp); for(i=0;i