423,321 Members | 1,178 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 423,321 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
File Type: jpg IMG_20180222_193219.jpg (50.6 KB, 38 views)
Feb 24 '18 #1

✓ answered by donbock

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?

Share this Question
Share on Google+
8 Replies


weaknessforcats
Expert Mod 5K+
P: 9,163

Expert 100+
P: 2,378
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,378
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,378
The relevance of integers versus floating-point is that
  1. There are a finite number of integer scores
  2. Integer scores can be reliably compared for equality
Mar 10 '18 #7

Expert 100+
P: 2,378
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<n;i++)
{
counter=0;
for(j=2;j<arx[i];j++)
{
if(arx[i]%j==0)
{
counter=1;
break;
}
}
if(counter==0)
{
printf("\nprime numbers are %d",arx[i]);
}
}



fclose(fp);
free(arx);
return 0;

}


i want to find and print composite and prime number...waht should i do?? help me please
Mar 15 '18 #9

Post your reply

Sign in to post your reply or Sign up for a free account.