LINEAR SEARCH IN AN ARRAY
#include<stdio.h>void main()
{
int a[10],i,j,n,count=0;
printf("enter the array limit:\n");
scanf("%d",&n);
printf("enter the array elemants:\n");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
if(a[i]==a[j])
{
count=count+1;
}
}
printf("%d repeats %d times\n",a[i],count);
}
}
Comments
Post a Comment