You try it first and post your best shot. You should know that a for loop is coded sometime similar to this: for(int i = 0; i < 5; i++). All you have to do is substitute the variables in what I just posted with what you posted.
First you understand how a for loop works.
Then understand all the pieces of the for loop expression.
Next, look at the posted code and figure out which of those pieces are there.
Put those pieces into the for loop syntax
I dont understand this.I have done other example.The code is suppose to convert 123456 to 654321 but i dont understand why i need y=y*10 and y+x %10.What is the modulus doing here???.These complications are preventing me from otherwise doing a straight-forward 'for' loop.
but i dont understand why i need y=y*10 and y+x %10
if you'd want to convert it you need to understand how the code works using the while loop first
My advice would be to trace the code by printing out the value of x and y in the loop after every operation or do it manually using a pen and paper
lastly take note of the initialization of variable y and x before the while loop,that should help you in the initializing content of the for loop