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

C++ examples for Statement:for

Description

Drawing Patterns with Nested for Loops 3

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

Demo Code

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

Result


Related Tutorials