Advertisement
edensheiko

C_rec_Q1

Feb 13th, 2021
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.54 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int rec_func(double*/*can be called also as double a[]*/, int, double);  //decletion
  4.  
  5. int main()
  6. {
  7.  
  8.     double arr[7] = { 2,5,8,9.3,11.5,17.4,20.5 };
  9.     double a = 25.4;
  10.     int b = rec_func(arr, 7, a);
  11.     printf("%d", b);
  12. }
  13.  
  14. int rec_func(double* arr, int size, double num)
  15. {
  16.  
  17.     if (size <= 1)
  18.     {
  19.         return 0;
  20.     }
  21.     if (arr[size - 1] + arr[size] == num) // algorithm (WORNG) needed to check the docmation on LECTURS.
  22.     {
  23.         return 1;
  24.     }
  25.  
  26.     rec_func(arr, size - 1, num);
  27.    
  28. }
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement