Tuesday, 5 May 2015

C++ Program to Print Equilateral Star Triangle

Print Equilateral Star Triangle in C++


Problem Description: This program prints equilateral Star triangle using for loops in C++.


Note: Run this program using DevC++




#include<iostream>

using namespace std;





int main()

{

     int lines,space,stars;

     for(lines=20;lines>=1;lines--)

     {

     for(space=20-lines;space>=0;space--)

     {

     cout << " " ;                                  

     }           

     for(stars=1;stars<=(2*lines-1);stars++)

     {

     cout << "*" ;                                      

     }                 

     cout << endl;

     }

    

     system("pause");

     return 0;   

}



1 comment:

  1. C++ Program to Print Triangle of Stars

    Print triangle of stars is depend of two concept, first you need outer loop for line break and inner loop for increment and decrements.

    ReplyDelete