(2.2) What value does function evaluate return when called with a value 4: int evaluate (int n) { if(n== 0) return 0; el
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
(2.2) What value does function evaluate return when called with a value 4: int evaluate (int n) { if(n== 0) return 0; el
(2.2) What value does function evaluate return when called with a value 4: int evaluate (int n) { if(n== 0) return 0; else return evaluate (n-1) + n*n; } Solution evaluate (4) evaluate (3) + 16 = evaluate (2) +9+16 = evaluate (1) + 4 + 9 + 16 = evaluate (0)+1+4+9+16 - 1+4+9+16 5+9+16 -14 +16 -30 [8]
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!