fork(1) download
  1. #include <stdio.h>
  2. int rLookupAr(int array[], int size, int target);
  3. int main()
  4. {
  5. int numArray[80];
  6. int target, i, size;
  7.  
  8. printf("Enter array size: \n");
  9. scanf("%d", &size);
  10. printf("Enter %d numbers: \n", size);
  11. for (i=0; i < size; i++)
  12. scanf("%d", &numArray[i]);
  13. printf("Enter the target number: \n");
  14. scanf("%d", &target);
  15. printf("rLookupAr(): %d", rLookupAr(numArray, size, target));
  16. return 0;
  17. }
  18.  
  19. int rLookupAr(int array[], int size, int target)
  20. {
  21. if(size < 1) return -1;
  22.  
  23. size--;
  24. if(array[size] == target) return size;
  25.  
  26. return rLookupAr(array, size,target);
  27. }
Success #stdin #stdout 0s 4392KB
stdin
5 2 1 3 2 4 2
stdout
Enter array size: 
Enter 5 numbers: 
Enter the target number: 
rLookupAr(): 3