• + 1 comment

    because we have to print sum in output. So , in for loop we traverse all element and add it in variable names sum and display it eg - we have array={1,2,3,4,5} when we run loop from i=0 it add a[0] (i.e - 1) in sum variable , similarly we run it till i=4 (i.e -5) . so sum=1+2+3+4+5

    i'm not good in explaining but hope it helps :)

    • + 0 comments

      thanku so much i got it :) thanku is less to u. u solve my problem in a second. i search this so much on chatgpt also but dont got this :)