0
I CANT UNDERSTAND THE EXECUTION OF THE PROGRAM.
calc <- function(a, b) { res <- 0 for(x in a:b) { res <- res + x } return(res) } print(calc(4, 7))
4 Réponses
+ 1
What part exactly don't you understand?
The for-loop iterates over the range of [a; b]. On each iteration the current number is added up to result.
+ 1
You can re-read the lesson about loops as often as you like.
4+5+6+7 = 22
+ 1
Thank you so much Lisa for Explanation..
0
The output is 22,i cant understand how the loop execute and how the output is 22.