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