Pattern Programs
C++ nested loops and spaces. Count on paper first or the triangle leans.
6 programs · open one, then the next
Start with Right Half Pyramid- 01Right Half PyramidBeginnerRight-half star pyramid in C++: row i prints i stars. Nested loops. rows=5 → 1..5 stars.Open example →cpp#include <iostream> using namespace std; int main() {
- 02Left Half PyramidBeginnerLeft-half (right-aligned) pyramid in C++. Print (rows-i) space-pairs, then i stars.Open example →cpp#include <iostream> using namespace std; int main() {
- 03Full PyramidIntermediateCentered star pyramid in C++. Row i: rows-i spaces, then 2*i-1 stars.Open example →cpp#include <iostream> using namespace std; int main() {
- 04Inverted PyramidIntermediateInverted star pyramid in C++. Count i down from rows. Same 2*i-1 stars as the full pyramid.Open example →cpp#include <iostream> using namespace std; int main() {
- 05Number PatternBeginnerNumber triangle in C++: row i prints 1..i. Same loops as the right-half pyramid, j instead of *.Open example →cpp#include <iostream> using namespace std; int main() {
- 06Pascal's TriangleAdvancedProgram to print Pascal's triangleOpen example →cpp#include <iostream> using namespace std; int main() {