Monday, 23 November 2015

C++ Program To Print A Given Reverse STAR Pattern

Problem :- Write A C++ Program To  Print A Given Reverse STAR Pattern Using As-trick ( * ) .


                                      ***********
                                        *********
                                          *******
                                            *****
                                             ***
                                               *

Logic :- For Printing any pattern remember always use For loop .In mostly pattern two for loops require first loop for Row and second for Column .May Be in your pattern for loop can be use parallel or Nested according to pattern you have to use if you don't know about how to print pattern then i refer first print this pattern by Own
C++ Program To Print A Given Triangle of STARS

Solution :-

#include<iostream>
using namespace std;

int main()
{
//By-Ghanendra Yadav 
int i,n, j, k;

cout<<"Enter How Many Times You Want To Print Pattern\n";
cin>>n;

for(i=n;i>=1;i--)
{
for(j=n;j>i;j--)
{
cout<<" ";
}
for(k=1;k<(i*2);k++)
{
cout<<"*";
}
cout<<"\n";
}
return 0;
}

Output:-

C++ Program To  Print A Given Reverse STAR Pattern

No comments:
Write comments

Recommended Posts × +