C++ Example – C++ Program to Print Triangle of Stars




cpp tutorials
cpp tutorials

C++ Programming Source Code to Print Pyramid and Triangles.

#include <iostream>
using namespace std;
int main()
{
  int i,j,k;
  for(i=1; i<=5; i++)
    {
      for(j=4; j>=i; j--)
        {
          cout<<" ";
        }
      for(k=1; k<=(2*i-1); k++)
        {
          cout<<"*";
        }
      cout<<"\n";
    }
  return 0;
}

/*

OUTPUT:
    *
   ***
  *****
 *******
*********

*/

Different ways of Putting the above question

  • C++ Programming Source Code to Print Pyramid and Triangles.
  • C++ Program To Print Pattern (Triangle) of Stars
  • C++ Program to Print Star Pyramid Patterns
  • C program to print patterns of numbers and stars

 

 


Partner Sites

VideoToGifs.com

EasyOnlineConverter.com

SqliteTutorials.com





Leave a Reply

Your email address will not be published.


*