SOLO Learn STUCK

Write your question here.can someone help me understand what im missing or how im missing it?

Challange 1 module6:
Fill in the blanks to print the sum of the array elements to the screen.

Double sum=0.0;
___(inti=0,i< 10; ++i) {
sum ___arr[i];
}
cout<<___;


Hello there,

I Don't know precise what your question is,
but i assume you want the sum of the array:
1
2
3
4
5
double sum = 0;
for (int i = 0; i < 10; i++)
     sum+=yourArray[i];    
for (int i = 0; i < 10; i++)
     cout<< sum << endl;    


Greetz
Last edited on
So there is 3 blanks right, the first blank I got FOR that's right second blank only takes 2 digit value and the 3rd blank it's SUM that's it , I know you child end line with endl; but the challenge is more focus on those 3 blanks.

So to get the answer to that 2 digits response that we are looking for we have to do the math and that's where I'm lost cut I can't recall what i++ means
Last edited on
Look at RDK's line 3. (i've no idea why he's added a second for loop on line 4 though).

I can't recall what i++ means

that's just incrementing i at each iteration of your for loop.
Last edited on
So your saying the new problem will read 1 < 10 because if i means increment den the question is not if 0 < 10 am i right?

I mean I know that the only accepted answer will be and had to be 2 characters or values,

_ _(int i=0,i< 10; ++i)

Now if ++ means increment then how am I incrementing a i? The value of i is 0 and if I'm going to increment it ++i then by how much? What will be the final value?

I know there's a big difference between

+ & ++

And I know that theirs a difference if the + or ++ get put before or after the value.

Right?

Dam I fell in love with c++ and now I'm getting beating by 3 char lol smh
So your saying the new problem will read 1 < 10 because if i means increment den the question is not if 0 < 10 am i right?

I have no idea what this means. All I was saying that this construct:

1
2
3
4
for (int i = 0; i < 10; i++)
{
    // do stuff
}    


will loop from i=0 to i=9. in other words TEN times. it will loop until your condition (which in this case is i<10) becomes false.
So what is the answer for that then? Cuz it has only space for 2 digits

sum __arr[i];

What is that sum?
I told you in my post. Look at RDK's line 3!
it can be [i] if thats what you mean cuz that wud be only one digit to input on my solo learn app and the app wants you to input 2 digits

sum+=yourArray[i];
Oh my god are you shit'n me? Lol it work wow I completely forgot all about those symbols (+=)

Thanks RBK!!!
And thanks for pointing out rbk's code Mutexe.
Topic archived. No new replies allowed.