-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLinear_Search.c
More file actions
36 lines (33 loc) · 780 Bytes
/
Linear_Search.c
File metadata and controls
36 lines (33 loc) · 780 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include<stdio.h>
//to Sreach 89891245
int main(){
int n=15;
long arr[15]={89123452,12345678,98765342,
19876543,13579086,24680975,
10293847,10385749,81238450,
91876534,64590285,89891245,
89076253,98766789,24689742};
int i;
int c=1;
long key=89891245;
while(c==1){
int q=1;
int flag=0;
printf("Enter Key to be searched in array:-> %d\n",key);
printf("By Using Linear Sreach:->\n");
for(i=0;i<n;i++){
if(arr[i]==key){
flag=1;
printf("\nKey Found!! @ %d index",i);
break;
}else{
continue;
}
}
if(flag==0){
printf("\nKey Not Found!!");
}
c=0;
}
printf("\n\nKEVIN PATEL\n17CE074\n");
}