+ 7

who understands this code , please explain🙏

https://code.sololearn.com/cJ2rrIsHxblg/?ref=app

12th Nov 2018, 10:28 PM
Lana Mironchik
Lana Mironchik - avatar
5 odpowiedzi
+ 8
the variable i iterates 2 times and the j 3 times i has following value in iteration 1,2 within the second for loop i looks like this 111222 And j looks like this 012012 Now you multiply the values what results in following output Output 1 * 0 0 1 * 1 1 1 * 2 2 2 * 0 0 2 * 1 2 2 * 2 4
12th Nov 2018, 10:36 PM
Mbrustler
Mbrustler - avatar
+ 8
First step is i = 1 and j = 0 i + j = 1, and is less than 5 and is print i * j (1 * 0). 2. I = 1 j = 1, I + j = 2 less than 5 not break do it operation I * j = 1. 3. I = 2 j = 0, I + j = 2 less than 5 not break do it operation I * j = 0. 4. I = 2 j = 1, I + j = 3 less than 5 not break do it operation I * j = 2. 5. I = 2 j = 2, I + j = 4 less than 5 not break do it operation I * j = 4. And for loop don't have more moves and is end.
12th Nov 2018, 10:43 PM
Izaak GOLDSTEIN
Izaak GOLDSTEIN - avatar
+ 4
Edward Foster , ok, bro) Don't worry)
13th Nov 2018, 7:52 AM
Lana Mironchik
Lana Mironchik - avatar
0
the two loops goes normal. as no way i or j get more than 2 and comblete (the fors conditions) so the if condition wont matter.
13th Nov 2018, 12:44 PM
محمد روبي
محمد روبي - avatar
- 1
Bro, take a deep breath and get the answer from other people, sorry im not helpfull, BTW: I dont know or understand Java Code! Sorry!
13th Nov 2018, 2:01 AM
Edward Foster
Edward Foster - avatar