Skip to content

Commit e508873

Browse files
authored
Merge pull request #3 from AkarshAnilkumar/main
Add files via upload
2 parents bd458e1 + 8f27701 commit e508873

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

_11.linearsearch.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#include <stdio.h>
2+
int main()
3+
{
4+
int a[10], i, item,n;
5+
printf("\nEnter number of elements of an array:\n");
6+
scanf("%d",&n);
7+
printf("\nEnter elements: \n");
8+
for (i=0; i<n; i++)
9+
scanf("%d", &a[i]);
10+
printf("\nEnter item to search: ");
11+
scanf("%d", &item);
12+
for (i=0; i<=9; i++)
13+
if (item == a[i])
14+
{
15+
printf("\nItem found at location %d", i+1);
16+
break;
17+
}
18+
if (i > 9)
19+
printf("\nItem does not exist.");
20+
return 0;
21+
}

0 commit comments

Comments
 (0)