Skip to content

Commit d607eae

Browse files
authored
Create linears.c
1 parent b895794 commit d607eae

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

Searches/linears.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#include<stdio.h>
2+
3+
int main()
4+
{
5+
int a[20],i,x,n;
6+
printf("How many elements?");
7+
scanf("%d",&n);
8+
9+
printf("Enter array elements:\n");
10+
for(i=0;i<n;++i)
11+
scanf("%d",&a[i]);
12+
13+
printf("\nEnter element to search:");
14+
scanf("%d",&x);
15+
16+
for(i=0;i<n;++i)
17+
if(a[i]==x)
18+
break;
19+
20+
if(i<n)
21+
printf("Element found at index %d",i);
22+
else
23+
printf("Element not found");
24+
25+
return 0;
26+
}

0 commit comments

Comments
 (0)