//DATA STRUCTURE
//TOPIC:LINEAR SEARCH C CODE
//AUTHOR:DARSHIT VORA
#include < stdio.h >
#include < conio.h >
void main()
{
int a[5]={23,1,3,4,56};
int sk,flag=0,pos,i;
clrscr();
printf("Enter the element u want to search");
scanf("%d",&sk);
for(i=0;i<5;i++)
{
if(a[i]==sk)
{
flag=1;
pos=i;
}
}
if(flag==1)
{
printf("\nelement %d found at pos %d",sk,pos);
}
else
printf("\nElement not found");
getch();
}
//TOPIC:LINEAR SEARCH C CODE
//AUTHOR:DARSHIT VORA
#include < stdio.h >
#include < conio.h >
void main()
{
int a[5]={23,1,3,4,56};
int sk,flag=0,pos,i;
clrscr();
printf("Enter the element u want to search");
scanf("%d",&sk);
for(i=0;i<5;i++)
{
if(a[i]==sk)
{
flag=1;
pos=i;
}
}
if(flag==1)
{
printf("\nelement %d found at pos %d",sk,pos);
}
else
printf("\nElement not found");
getch();
}
Comments
Post a Comment