Monday, September 10, 2018

Inverted Pyramid of stars

/* Program to print Pattern - Reverse Triangle of stars
*****
***
  *
*/
#include<iostream>
#include<conio.h>
using namespace std;
main()
{
int num; // To input number of lines
cout<<"Enter Number "; cin>>num;
int r,c;
for(r=num; r>=1; r--) {
for(int sp=1;sp<=num-r;sp++) cout<<" ";
for(c=1 ; c<=2*r-1; c++)
{
cout<<"*"; // will print * in a single line
}
cout<<"\n"; // At end of inner loop next line will
// come in a new line
}
getch();
}

No comments:

Post a Comment