0% found this document useful (0 votes)
5 views

Star Pyramid

The document is a C++ program that prints out a pyramid pattern of asterisks. It uses nested for loops to print spaces and asterisks, with the number of asterisks increasing by one on each line as the number of spaces decreases by one, to output a pyramid shape with 5 rows where the top row has 1 asterisk and the bottom row has 5.

Uploaded by

Kyo Kunsagi
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Star Pyramid

The document is a C++ program that prints out a pyramid pattern of asterisks. It uses nested for loops to print spaces and asterisks, with the number of asterisks increasing by one on each line as the number of spaces decreases by one, to output a pyramid shape with 5 rows where the top row has 1 asterisk and the bottom row has 5.

Uploaded by

Kyo Kunsagi
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

>

*
* *
* * *
* * * *
* * * * *

#include <iostream

int main() {

int n = 5; // Number of rows

for (int i = 1; i <= n; i++) {

// Print spaces

for (int j = 1; j <= n - i; j++) {

std::cout << " ";

// Print asterisks

for (int k = 1; k <= i; k++) {

std::cout << "*";

// Move to the next line

std::cout << std::endl;

return 0;

You might also like