/* occurrence of given element in an array */
#include<stdio.h>
#include<conio.h>
main()
{
int a[10],n,m,i,p,count=0;
printf("\n enter the size of the array");
scanf("%d",&n);
printf("\n enter the elements into the array");
for(i=0;i<n;i++)
scanf("%d",&a[i]);
printf("\n enter the element to find");
scanf("%d",&p);
for(i=0;i<n;i++)
{
if(p==a[i])
count++;
}
printf("\n %d is exists %d times in the array",p,count);
getch();
}
No comments:
Post a Comment