Thursday, September 6, 2018

pattern 7 - printing numbers - part 3 video

#include<iostream>
#include<conio.h>
using namespace std;
main()
{
int num; // To input number of lines
cout<<"Enter Number "; cin>>num;

for(int r=num; r>=1; r--) {
for(int sp=1;sp<=num-r;sp++)
cout<<" ";
for(int c=r ; c>=1; c--)
{
cout<<c; // 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