Wednesday, October 5, 2016

C++ Program To Display inverted half pyramid using * and numbers

* * * * *
* * * *
* * * 
* *
*
#include <iostream>
using namespace std;
int main() 
{
    int i,j,rows;
    cout << "Enter the number of rows: ";
    cin >> rows;
    for(i=rows;i>=1;--i)
    {
        for(j=1;j<=i;++j)
        {
           cout << "* ";
        }
        cout << endl;
    }
    return 0;
}

No comments:

Post a Comment