Numerical Program

Mode Method Definition

A statistical term that refers to the most frequently occurring number found in a set of numbers. The mode is found by collecting and organizing the data in order to count the frequency of each result.

Program of Mode in C Language

  #include<stdio.h>
  #include<conio.h>
  
  void main()
  {
    int a[10],b[10]; int k=0,j,p,i,count=1,n,big;
    clrscr();
    printf("Enter the number of terms : ");
    scanf("%d",&n);
    printf("Enter elements:");
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(i=0; i<n; i++)
    {
        //printing element
        printf("%d ",a[i]);
    }
    for(i=0; i<n; i++)
    {
        for(j=i+1; j<=n; j++)
        {
            if(a[i]==a[j])
            count++;
        }
        b[k]=count;
        k++;
        count=1;
    }
    printf("n");
    for(i=0; i<k; i++)
    {
        printf("%d ",b[i]);
    }
    big=b[0];
    for(i=1;i<=k;i++)
    {
        if(b[i]>big)
        {
            big=b[i];
            p=i;
        }
    }
    printf("\nPresent at position : %d ",p);
    printf("\nMode is %d Occuring %d times ",a[p],b[p]);
    getch();
  }
    

Output

Post Your Comment

Some Useful Tricks of Windows

Follow us on Facebook

Advertisement