0

for (int a = 0; a < 50; a+=10) HOW DO THEY GET THE 10 SOMEONE PLEASE HELP @_@

18th Jan 2017, 4:58 PM
Jade-leroy
Jade-leroy - avatar
7 ответов
+ 9
What do you mean by "get the 10". Who are "they". I have more questions than answers lol.
18th Jan 2017, 5:02 PM
Hatsy Rei
Hatsy Rei - avatar
+ 5
Do you mean the 10 in a+=10?
18th Jan 2017, 5:03 PM
Saumya
Saumya - avatar
+ 4
In simple term, this for loop first initializes the value of a as 0, then it checks whether the value of a<50, then since it has no code block so it direct goes for the increment part, i.e a+=10 which means a=a+10, further it again checks the exit condition a<50, the loop keeps running when the condition is true and stops when the condition is not satisfied, i.e when a=50. Hence the output will be as given by harsh. If a<40, the loop will stop when a=40. Coming to the a+= part, it can be anything. It may be any increment, decrement, multiplication or division or modulo statement.
19th Jan 2017, 3:20 AM
Saumya
Saumya - avatar
+ 1
if you print the value of a then it will print 0 10 20 30 40 because a += 10 is same as a = a + 10
18th Jan 2017, 5:03 PM
harsh
+ 1
@hatsy_rei LOL @harsh explain abit more @saumya yes @mohammed_anas @_@
18th Jan 2017, 8:13 PM
Jade-leroy
Jade-leroy - avatar
0
IM still confused guys.. what does A's value have to do with the 10. what if a<40 ? what will a+=?
18th Jan 2017, 8:11 PM
Jade-leroy
Jade-leroy - avatar
- 1
it's simple yaar a=a+10 as a value is zero ..so then a=0+10 which is 0
18th Jan 2017, 5:42 PM
MOHAMMED ANAS
MOHAMMED ANAS - avatar