Monday, 23 November 2015

C++ Program To Print A Given Triangle of STARS

Problem :- C++ Program To Print A Given Triangle of STARS 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 Pattern Or Series Like 12345,5432,234,43,3

Solution :-

#include<iostream>
using namespace std;
int main()
{
//By-Ghanendra Yadav
int i,j,k,n;

cout<<"Enter How Many Row Print With Pattern\n";
cin>>n;

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

Output:-

C++ Program To Print A Given Triangle of STARS

Extreme Recommended:- Like our Facebook Page or Join our Facebook Group and Google plus Community for up-to-date. If you have any Query or Question you can ask in the group, I will Try To Solve your Query and try to answers of your Questions withing 24 Hours, You can also Email me or comment below Please suggest to your Friends to join and like our page and don't forget to Subscribe. Enter your Email and click to subscribe.

Ghanendra Yadav

Ghanendra Yadav

Hello, I Am Ghanendra Yadav Owner of This Blog, I am professional Blogger and Programmer. I Love Programming, Logo Making, And Banner Designing. My Highest Qualification is MCA From NIT Warangal. You Can Find Me On Social Media Through Below Link And If You Have Any Query Related To Programming And Other Subject Comment Below or You Can Mail Me I Will Try To Answer Within 24 Hours Email:- yghanendra@student.nitw.ac.in

Find me on Social Media

Facebook | Twitter | Google+ | RSS Feed

No comments:

Post a Comment