+ 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
8 Respostas
+ 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