Drawing Patterns with Nested for Loops 2 - C++ Statement

C++ examples for Statement:for

Description

Drawing Patterns with Nested for Loops 2

*****************
****************
***************
**************
*************
************
***********
**********
*********
********
*******
******
*****
****
***
**

Demo Code

#include <iostream>
int main(int argc, const char *argv[]) {
    for (int i = 10; i >= 1; i--) {
        for (int j = 1; j <= 10; j++) {
            std::cout << ((j <= i) ? '*' : ' ');
        }//  w  w w.j  a v a  2 s .  c  o  m
        std::cout << std::endl;
    }
    return 0;
}

Result


Related Tutorials