0
for (int a = 0; a < 50; a+=10) HOW DO THEY GET THE 10 SOMEONE PLEASE HELP @_@
7 Answers
+ 9
What do you mean by "get the 10".
Who are "they".
I have more questions than answers lol.
+ 5
Do you mean the 10 in a+=10?
+ 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.
+ 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
+ 1
@hatsy_rei LOL
@harsh explain abit more
@saumya yes
@mohammed_anas @_@
0
IM still confused guys.. what does A's value have to do with the 10.
what if a<40 ? what will a+=?
- 1
it's simple yaar a=a+10 as a value is zero ..so then a=0+10 which is 0