We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 39b77f0 commit b7851fcCopy full SHA for b7851fc
1 file changed
LinearSearch/C/LinearSearch.c
@@ -0,0 +1,25 @@
1
+
2
+#include <stdio.h>
3
4
+int main()
5
+{
6
+ int array[100] search, c, n=10; // n is the number of elements to be stored.
7
8
+ int array[n]; //array[] is used to store the element
9
10
+ printf("Enter the number to search\n");
11
+ scanf("%d", &search);
12
13
+ for (c = 0; c < n; c++)
14
+ {
15
+ if (array[c] == search) /* if required element found */
16
17
+ printf("%d is present at location %d.\n", search, c+1);
18
+ break;
19
+ }
20
21
+ if (c == n)
22
+ printf("%d is not present in array.\n", search);
23
24
+ return 0;
25
+}
0 commit comments