0

For( ; number !=0; number /=10)

I didn't understand it can you help me with this

17th Nov 2018, 6:57 PM
Basit Mir
Basit Mir - avatar
5 odpowiedzi
+ 1
What exactly do you not understand?
17th Nov 2018, 7:37 PM
HonFu
HonFu - avatar
+ 1
Okay. Do you understand the basic pattern that's in every lesson? for (int i=0; i<10; ++i) The first part sets up a variable at 0; the next part says that the loop is to be repeated until i becomes 10; the third part increases i with every loop. So that loop runs 10 times. You can define all sorts of conditions and actions to steer a loop. In your case, there is no need to set up a variable because 'number' was already defined before. So the first slot remains empty. The second slot, the condition says that the loop shall go on as long as number is not zero. And in the third slot, number is divided by 10, so eventually it will be zero and the loop will be over (under the condition that number is an int).
17th Nov 2018, 7:44 PM
HonFu
HonFu - avatar
17th Nov 2018, 7:12 PM
Basit Mir
Basit Mir - avatar
0
For loop statement
17th Nov 2018, 7:39 PM
Basit Mir
Basit Mir - avatar
0
number=num for(;number!=0;number/=10) is equivalent to for(number=num;number!=0;number/=10) If it was the problem
17th Nov 2018, 7:44 PM
Roneel
Roneel - avatar