Number Loop for .625 then 1.625 then 3.625 and etc

I am a noob and I need help with a number loop starting with .625 then to 1.625 then 3.625 then 5.625 and so on. Can anyone help me with this?

1
2
3
4
5
6
7
8
9
10
  double column_width = .625;
    
    while (column_width < 20)
    {
        if (column_width != 2.625 /*&& column_width != 4.625 && column_width != 6.25 && column_width != 8.625 &&
                column_width != 10.625 && column_width != 12.625 && column_width != 14.625 && column_width != 16.625 &&
                column_width != 18.625*/)
        cout << "Column width = " << column_width << " inches" << endl;
        column_width = column_width + 2;
    }
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
include <iostream>

int main()
{
    // .625 then to 1.625 then 3.625 then 5.625 then 7.625
    {
        double v = 0.625 ;

        for( int n = 0 ; n < 10 ; ++n )
        {
            std::cout << n << ". " << v << '\n' ;
            if( n == 0 ) v += 1 ;
            else v += 2 ;
        }
    }

    std::cout << "\n----------------------------\n" ;

    // .625 then to 1.625 then 3.625 then 6.625 then 10.625
    {
        double v = 0.625 ;

        for( int n = 0 ; n < 10 ; ++n )
        {
            std::cout << n << ". " << v << '\n' ;
            v += (n+1) ;
        }
    }
}
Topic archived. No new replies allowed.