For Loop

I just want to know how to write a for loop to check each value to the 0.1 place rather than a whole number. I know for example doing (int i=0; i<5;i++) goes by the numbers 1,2,3,4,5 but what if I want to check 1.1,1.2,1.3 and so on. I know that the i++ goes by a whole number. How would i change that to check decimal places.

1
2
for (float i = 0; i <= 10; i += 0.1)
// do your stuff 
Keep the 'i' as int. Compute a float from it on every iteration, within the body of the loop.
for (double i = 0.0; i < 5.0; i += 0.1)

Although why you would want to do that I don't know.
1
2
for ( int i = 10; i < 60; ++i )
    cout << i / 10.0 << '\n';
Topic archived. No new replies allowed.