-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path155Array.c
More file actions
47 lines (47 loc) · 830 Bytes
/
Copy path155Array.c
File metadata and controls
47 lines (47 loc) · 830 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
37
38
39
40
41
42
43
44
45
46
47
//Linear search program
#include<stdio.h>
#define size 5
void insert(int x[])
{
int i;
for(i=0;i<size;i++)
{
scanf("%d",&x[i]);
}
}
void display(int x[])
{
int i;
for(i=0;i<size;i++)
{
printf("%d\t",x[i]);
}
}
void l_search(int x[])
{
int i,fl=0,key;
printf("\nEnter the value you want search:\n");
scanf("%d",&key);
for(i=0;i<size;i++)
{
if(x[i]==key)
{
fl=1;
break;
}
}
if(fl==0)
printf("\nNo such value found");
else
printf("\n%d found at %d location",key,i+1);
}
int main()
{
int a[size];
printf("\nEnter the array elements:\n");
insert(a);
printf("\nThe array elements are:\n");
display(a);
l_search(a);
return 0;
}