Write C++ program that prints following shape - Create generic programs
*****
Answers
Answer:
To understand this example, you should have the knowledge of the following C++ programming topics:
C++ if, if...else and Nested if...else
C++ for Loop
C++ while and do...while Loop
C++ break and continue Statement
List of Source Code
Print triangle using *, digits and characters
Print inverted triangle using * and digit
Code to Print pyramid
Code to Print reverse pyramid
Code to Print Pascal's traingle
Code to Print Floyd's triangle
Programs to print triangles using *, numbers and characters
Example : Program to print half pyramid using *
*
* *
* * *
* * * *
* * * * *
Source Code
#include <iostream>
using namespace std;
int main()
{
int rows;
cout << "Enter number of rows: ";
cin >> rows;
for(int i = 1; i <= rows; ++i)
{
for(int j = 1; j <= i; ++j)
{
cout << "* ";
}
cout << "\n";
}
return 0;
}