0

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

18th Jan 2017, 4:58 PM
7 Respostas
+ 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
+ 5
Do you mean the 10 in a+=10?
18th Jan 2017, 5:03 PM
Saumya
+ 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
+ 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