forked from wafarifki/Hacktoberfest_2021
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlinear_search.c
51 lines (45 loc) · 802 Bytes
/
linear_search.c
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
48
49
50
51
#include<stdio.h>
#include<stdlib.h>
void input(int array[], int size )
{
printf("Enter the size of the array\n");
scanf("%d",&size);
printf("Enter the elemts in array\n");
for(int i=0; i<size ; i++)
{
scanf("%d",&array[i]);
}
int temp = 0;
int element;
for(int i=0; i<size ; i++ )
{
printf("%d ",array[i]);
}
printf("\n");
printf("Enter the element to search in array\n");
scanf("%d",&element);
for(int i=0; i<size ; i++ )
{
if(element = array[i])
{
temp=1;
}
else
{
continue;
}
}
if(temp)
{
printf("found element\n");
}
else
{
printf("Not found\n");
}
}
void main()
{
int array[100] , size ;
input(array,size);
}