Commit 8398fa2
committed
feat: Search for an element in an array using linear search
🧠 Logic:
- Initialize a fixed array of integers.
- Read a key from user input.
- Traverse the array using a loop and compare each element with the key.
- If found, print the index and exit the program immediately.
- If loop completes without finding the key, print "Not Found".
Signed-off-by: Somesh diwan <[email protected]>1 parent e093752 commit 8398fa2
1 file changed
+5
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | | - | |
| 4 | + | |
6 | 5 | | |
7 | 6 | | |
8 | 7 | | |
| |||
11 | 10 | | |
12 | 11 | | |
13 | 12 | | |
14 | | - | |
15 | | - | |
| 13 | + | |
16 | 14 | | |
17 | 15 | | |
18 | | - | |
19 | | - | |
| 16 | + | |
| 17 | + | |
20 | 18 | | |
21 | 19 | | |
22 | 20 | | |
23 | 21 | | |
24 | | - | |
| 22 | + | |
0 commit comments