Advertisement
Rehan_Rahman26

Function Problem 02

Oct 7th, 2021
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.28 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int maxValue(int A[], int n)
  5. {
  6. if (n == 1)
  7. return A[0];
  8. return max(A[n-1], maxValue(A, n-1));
  9. }
  10.  
  11. int main()
  12. {
  13. int A[] = {1, 4, 45, 6, -50, 10, 2};
  14. int n = sizeof(A)/sizeof(A[0]);
  15. cout << maxValue(A, n);
  16. return 0;
  17. }
  18.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement