#include<stdio.h>
#include<conio.h>
int main()
{
int list[100],n,i,x,p;
printf("enter the size of list");
scanf("%d",&n);
printf("enter the elements");
for(i=0;i<n;i++)
scanf("%d",&list[i]);
p=0;
printf("enter the element to be searched");
scanf("%d",&x);
for(i=0;i<n;i++)
{
if(list[i]==x)
{
p=i+1;
}
}
if(p>0)
printf("the location of the element is :%d %d ",x,p);
else
printf("try again");
getch();
return 0;
}
#include<conio.h>
int main()
{
int list[100],n,i,x,p;
printf("enter the size of list");
scanf("%d",&n);
printf("enter the elements");
for(i=0;i<n;i++)
scanf("%d",&list[i]);
p=0;
printf("enter the element to be searched");
scanf("%d",&x);
for(i=0;i<n;i++)
{
if(list[i]==x)
{
p=i+1;
}
}
if(p>0)
printf("the location of the element is :%d %d ",x,p);
else
printf("try again");
getch();
return 0;
}
No comments:
Post a Comment
Note: only a member of this blog may post a comment.