Header Ads

  • Breaking News

    Print Pyramid of asteric in C++

    In C++ we write the code in following steps


    int main()
     {
     int space, rows;
    cout <<"Enter number of rows: ";   cin >> rows;
    for(int i = 1, k = 0; i <= rows; ++i, k = 0)
          { for(space = 1; space <= rows-i; ++space)
               { cout <<" "; }
       while(k != 2*i-1)
       { cout << "* "; ++k; }
    cout << endl; }

    return 0; }

    Hence the output is;


    More Example

    No comments

    Post Top Ad

    Post Bottom Ad