#include<stdio.h>//header file
#include<conio.h>//header file
void main() //starting of the main() function
{
int *b,flag=0,i,n,a[10]; //declaration of the variables
clrscr();
printf("program to search an element in an array using pointers");
printf("\n\n\n\t\t------------INPUT-------------");
printf("\n\nenter the elements in the array");
for(i=0;i<10;i++)
{
printf("\nenter the %dth element",i);
scanf("%d",&a[i]); //taking input from the user
}
printf("\nenter the element to be searched");
scanf("%d",&n);
b=a;
for(i=0;i<10;i++)
{
if(*(b+i)==n)
{
flag=1;
break;
}
}
if(flag==1)
{
printf("\n\n\n\t\t------------OUTPUT------------");
printf("\n\nthe element exists at %d",i);//printing output
}
else
{
printf("\n\n\n\t\t------------OUTPUT------------");
printf("\n\nelement doesnot exists");//printing output
}
getch();
}