Welcome

Hi! This blog is for beginners of c++ and java .You can check and pick codes for your programming assignments. This will also help you to understand the concepts of these programming languages. Its all about programming.

Diagrams By loops 3

Thursday, May 19, 2011

#include <iostream.h>

int main() {
    int i=0;
    int j=0;
    int k=0;

    for (i=0;i<4;i++){         // outer loop - for rows
        for (j=3;j>i;j--){  // inner for loop - for blank spaces
            cout << " ";      // print blank spaces
        }                    // end for loop - inner

        for (k=0; k<=i+j; k++)      // k <=i+j: to put asterisk on left side as well
            cout << "*";
        cout << endl;
    }                     // end for loop - outer

return 0;
} // end main