Advertisement
Guest User

Untitled

a guest
Jan 26th, 2020
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.67 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <assert.h>
  4.  
  5. #define ItemToFind 6
  6.  
  7. int main(int argc, char const *argv[]) {
  8.     int i;
  9.     int finish = 1;
  10.     int count = 0;
  11.     int amount = 0;
  12.     int array[amount];
  13.     printf("Array size? \n");
  14.     scanf("%d", &amount);
  15.     for(i=0; i < amount; i++) {
  16.         scanf("%d", &array[i]);
  17.     }
  18.     for(i=0; i<=amount; i++) {
  19.         while(i < amount && finish == 1){
  20.             count++;
  21.             printf("%d\n", array[i]);
  22.             if(array[i] == ItemToFind){
  23.                 count++;
  24.                 printf("Found in. %d counts\n" ,count);
  25.                 finish = 0;
  26.                 break;
  27.             }else{
  28.             printf("Not Found\n");
  29.             i++;
  30.             }
  31.         }
  32.        
  33.     }
  34.     if(finish == 1){
  35.         printf("Can't find\n");
  36.     }
  37.  
  38.     return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement