here you find the best simplest implement of programs

code_world

love programing and watch my all easy implement of program hope you like it

Thursday, 4 May 2017

program of linear search



                        linear search



#include<stdio.h>
#include<conio.h>
#define size 5
void main()
{
 int a[size],i,pos=-1,val;
 clrscr();
 printf("enter the element");
 for(i=0;i<size;i++)
 {
  scanf("%d",&a[i]);
 }
 printf("enter the value to be search");
 scanf("%d",&val);
 pos=0;
 for(i=0;i<=size;i++)
 {
   if(a[i]==val)
   {
   pos=val;
  printf("elemnt was found in %d\n",pos);
 }
 else
 {
  printf("element not found\n");
 }
}
 getch();
}


Share:

Related Posts:

0 comments:

Post a Comment