0% found this document useful (0 votes)
8 views

Linear Search

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Linear Search

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

#include<stdio.

h>

void main()

int a[10],n,i,s,count=0;

char choice,y;

printf("enter size of an array\n");

scanf("%d",&n);

printf("enter array elements \n");

for(i=0;i<n;i++)

scanf("%d",&a[i]);

printf("enter element you want to search\n=");

scanf("%d",&s);

for(i=0;i<n;i++)

if(s==a[i])

count=1;

break;

if(count==0)

printf("element not found");

else

printf("element found");

}
Output 1 :-

enter size of an array

enter array elements

456

enter element you want to search

=5

element found

=== Code Exited With Errors ===

Output 2:-

enter size of an array

enter array elements

9875

enter element you want to search

=4

element not found

=== Code Exited With Errors ===

You might also like