#include<stdio.h>
int main()
{
int a[50],n,i,x;
printf("Enter n:");
scanf("%d",&n);
printf("Enter %d number into array\n",n);
for(i=1; i<=n; i++)
{
scanf("%d",&a[i]);
}
printf("Enter element to be searched");
scanf("%d",&x);
for(i=1; i<=n; i++)
{
if(x==a[i])
{
break;
}
}
if(i<=n)
{
printf("The Element =%d is at %d", x,i);
} else {
printf("Element is not found");
}
return 0;
}
Note: Need to be arranged in compiler after copied
OutPut:
Enter n:5
Enter 5 number into array
3
6
7
2
9
Enter element to be searched3
The Element =3 is at 1