• + 1 comment

    include

    include

    include

    include

    int main() {

    /* Enter your code here. Read input from STDIN. Print output to STDOUT */    
    int n,sum=0;
    scanf("%d",&n);
    int arr[n];
    for(int i=0;i<n;i++){
        scanf("%d",&arr[i]);
    }
    for(int i=0;i<n;i++){
        sum += arr[i];
    }
    printf("%d",sum);
    
    return 0;
    

    }

    • + 1 comment

      **explian please why 'sum'?

      for(int i=0;i

      • + 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 :)