How to find the mode of an array??

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • k1ckthem1dget
    New Member
    • Nov 2006
    • 15

    How to find the mode of an array??

    I dont know how to find the mode of an array.

    I am to do the following.

    (1) Given the following:

    · A list of 11 integers; 1,2,3,3,3,2,2,1 ,3,4,5


    (2) The program should:

    · Creates an array from the source data list

    · Determines the “mode” of the array (mode is a proper statistical term that is the value that occurs “most often”)

    · The program should account for the “exception” that no “mode” occurs – no value in the array occurs more than once.


    Any help is appreciated. Thanks
  • Manjiri
    New Member
    • Nov 2006
    • 40

    #2
    Originally posted by k1ckthem1dget
    I dont know how to find the mode of an array.

    I am to do the following.

    (1) Given the following:

    · A list of 11 integers; 1,2,3,3,3,2,2,1 ,3,4,5


    (2) The program should:

    · Creates an array from the source data list

    · Determines the “mode” of the array (mode is a proper statistical term that is the value that occurs “most often”)

    · The program should account for the “exception” that no “mode” occurs – no value in the array occurs more than once.


    Any help is appreciated. Thanks


    Try out this.... U will get the ans..
    #include<stdio. h>

    int main()
    {
    int i,j,k=1,p,a[20],b[20],n,cnt=1,big;
    printf("Enter the maximum number of elements\n");
    scanf("%d",&n);
    printf("Enter the elements\n");
    for(i=1; i<=n; i++)
    scanf("%d",&a[i]);
    for(i=1; i<=n; i++)
    {
    for(j=i+1;j<=n; j++)
    {
    if(a[i]==a[j])
    cnt++;
    }
    b[k]=cnt;
    k++;
    cnt=1;
    }

    big=b[1];
    p=1;
    for(i=2; i<=n; i++)
    {
    if(big<b[i])
    {
    big=b[i];
    p=i;
    }
    }
    printf("The element that occurs offenly is %d\n",a[p]);
    printf("And it has occurred %d times\n",b[p]);
    return 0;
    }

    Comment

    • ovince01o
      New Member
      • Feb 2018
      • 5

      #3
      i dont know how to program mode

      i am given the following problem

      gets the scores for user
      short the scores
      find the mode and how many times it is used can u help me sir?

      Comment

      Working...