+ 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; }
8 Antworten
+ 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 💕💕🐯🐯
+ 3
RAMADAN : رمضان
I am brother 😣😣😣
+ 3
RAMADAN : رمضان no worry
Btw my name is rp Rakshit pahel
+ 2
💕💕♥♥⛄⛄ŘP⛄⛄♥♥💕💕 Sorry bro, I didn't mean to offend you, but you don't have a name
+ 2
💕💕♥♥⛄⛄ŘP⛄⛄♥♥💕💕 Thank you, Rakshit Bahel
+ 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
0
🧚Somya🌹 Thank you, I understand now