The bottom line of the code is to collect the elements of the array by loop But I want to understand it step by step | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

The bottom line of the code is to collect the elements of the array by loop But I want to understand it step by step

#include <iostream> using namespace std; int main() { int arr[ ] = {11, 35, 62, 555, 989}: int sum = 0; for (int x = 0; x < 5; x++) { sum += arr[x]; } Cout << sum << end1; return 0; }

1st Jun 2022, 12:59 AM
RAMADAN : رمضان
RAMADAN : رمضان - avatar
7 Answers
+ 8
First you take a array Then a variable sum as 0 Then make a for loop which move from 0 to 4 element Then add the number everytime in updated sum and at last got the sum of all number In this program there are 2 mistakes one in for loop = used between x and 5 And other mistake is in Sum+=arr[x] Hope it helps brother 💕💕🐯🐯
1st Jun 2022, 1:08 AM
Rakshit Pahel
Rakshit Pahel - avatar
+ 3
RAMADAN : رمضان I am brother 😣😣😣
1st Jun 2022, 2:27 AM
Rakshit Pahel
Rakshit Pahel - avatar
+ 3
RAMADAN : رمضان no worry Btw my name is rp Rakshit pahel
1st Jun 2022, 2:41 AM
Rakshit Pahel
Rakshit Pahel - avatar
+ 2
💕💕♥♥⛄⛄ŘP⛄⛄♥♥💕💕 Sorry bro, I didn't mean to offend you, but you don't have a name
1st Jun 2022, 2:33 AM
RAMADAN : رمضان
RAMADAN : رمضان - avatar
1st Jun 2022, 2:43 AM
RAMADAN : رمضان
RAMADAN : رمضان - avatar
+ 1
💕💕♥♥⛄⛄ŘP⛄⛄♥♥💕💕 Yes, I think I understood it now at first sum += arr[x].......0+[0]=11 sum += arr[x].......11+[1]=46 sum += arr[x].......46+[2]=108 sum += arr[x].......108+[3]=663 sum += arr[x].......663+[4]=1652 Thank you sister
1st Jun 2022, 1:29 AM
RAMADAN : رمضان
RAMADAN : رمضان - avatar
0
🧚Somya🌹 Thank you, I understand now
1st Jun 2022, 1:31 AM
RAMADAN : رمضان
RAMADAN : رمضان - avatar