Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Program to search an element using Linear Search.
- #include <stdio.h>
- #include <conio.h>
- void main () {
- int bool = 0, n, i, arr[10] = {
- 10, 4, 8, 22, 11, 3, 12, 90, 77, 34
- };
- clrscr ();
- printf ("Enter number to be searched: ");
- scanf ("%d", &n);
- for (i = 0; i < 10; i++) {
- if (n == arr[i]) {
- printf ("Match found at position %d: %d", i + 1, n);
- bool = 1;
- break;
- }
- }
- if (bool == 0) {
- printf ("Match not found.");
- }
- getch();
- }
Add Comment
Please, Sign In to add comment