COUNT THE NUMBER OF OCCURRENCE OF EACH NUMBER


#include<stdio.h>
#include<conio.h>
#define FOR for(i=0;i<n;i++)
void main()
{
int no[50],i,j,n,count=0;
clrscr();
printf("\n\n\t\tHow many elements in the array : ");
scanf("%d",&n);
printf("Input %n elements in the array :");
FOR
scanf("%d",&no[i]);
        FOR
{
for(j=0;j<n;j++)
{
      if(no[i]==no[j])
      count++;
}
 printf("\n\tAccurence of %d  = %d times",no[i],count);
 count=0;
}
getch();
}

0 comments: (+add yours?)

Post a Comment