Advertisement
aiNayan

2(iii)

Feb 24th, 2021
1,039
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.52 KB | None | 0 0
  1. #include <stdio.h>
  2. int main()
  3. {
  4.     int arr[100], s, i, n;
  5.     printf("Enter the number of values: ");
  6.     scanf("%d", &n);
  7.     printf("Enter the values: ", n);
  8.     for (i = 0; i < n; i++)
  9.         scanf("%d", &arr[i]);
  10.     printf("Enter the value to search: ");
  11.     scanf("%d", &s);
  12.     for (i = 0; i < n; i++) {
  13.         if (s == arr[i]) {
  14.             printf("%d found at %d index", s, i);
  15.             break;
  16.         }
  17.         else
  18.             printf("%d not found", s);
  19.         break;
  20.     }
  21.     return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement