Printing stars using nested loops
Edit Oh well, not using nested for... Sorry about that

int inc = 2;
for (int i = 1; i &gt;= 1; i += inc){
    std::cout&lt;&lt;std::string(i,'*')&lt;&lt;endl;
    if ( i == 5 )
        inc = -2;
}