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; }
C++ Program to Print Triangle of Stars
ReplyDeletePrint triangle of stars is depend of two concept, first you need outer loop for line break and inner loop for increment and decrements.