I can't understand.. can you please help me?

Sir's:

I have completed the program
But I don't understand fully how the reverse of strings works
This is the program:

for (i=0;i<x*0.5;i++)
{
ch=a[i];
a[i]=a[(x-1)-i];
a[(x-1)-i]=ch;
}

I can't understand this part
i<x*0.5 ?????

how did it became like that??

thank you for helping me in advance
i<x*0.5

This part just tells the for-loop to run for a certain amount of time. This time until i reaches " < x * 0.5)"

if x is for example 6. then the program will run 3 times. Because i = 0, and x*0.5 = 3.
Which means, i < 3.

Please look at bucky's tutorials on youtube, he is really good at explaining the basics -
https://www.youtube.com/playlist?list=PLAE85DE8440AA6B83

If you want to specifically learn about for-loops. Watch video number 22.
Topic archived. No new replies allowed.