#include<stdio.h>
main()
{
int a[100],i,n,ele,pos,flag=0;
clrscr();
printf("\nEnter the total number of elements\n");
scanf("%d",&n);
printf("\nEnter the elements one by one: \n");
for(i=0;i<n;i++)
scanf("%d",&a[i]);
printf("\nEnter the element to be searched\n");
scanf("%d",&ele);
for(i=0;i<n;i++)
{
if(a[i]==ele)
{
flag=1;
break;
}
}
if(flag==1)
printf("\n%d found in %d position",ele,i+1);
else
printf("\n%d NOT FOUND!!!\n",ele);
getch();
}
Comments
Post a Comment