C Program For Linear Search

/*L Search*/
#include<stdio.h>
#include<conio.h>
main()
{
int a[10],n,i,se,found=0;
clrscr();
printf("Enter the value of n");
scanf("%d",&n);
 for(i=0;i<n;i++)
 {
 printf("Enter the value of a[%d]",i);
 scanf("%d",&a[i]);
 }

 printf("Enter the searching element\n");
 scanf("%d",&se);

 for(i=0;i<n;i++)
 {
  if (a[i]==se)
  {
  printf("The element found\n");
  found=0;
  break;
  }
 }

if (found==0)
{
printf("The element not found\n");
}
}
Bhanu Namikaze

Bhanu Namikaze is an Ethical Hacker, Security Analyst, Blogger, Web Developer and a Mechanical Engineer. He Enjoys writing articles, Blogging, Debugging Errors and Capture the Flags. Enjoy Learning; There is Nothing Like Absolute Defeat - Try and try until you Succeed.

No comments:

Post a Comment