Make a Star Pyramid - MATLAB Cody - MATLAB Central

Problem 985. Make a Star Pyramid

Difficulty:Rate

Create a star pyramid. First line will have 1 star, second will have two stars and so on... a basic program which is easily done in c programming.

Example

 n = 3
 p = pyramid(n)

returns this string matrix in p

 '*  '
 '** '
 '***'

The output p is an n-by-n string matrix with spaces (ASCII=32) in the blank spots and '*' as shown.

Solution Stats

40.51% Correct | 59.49% Incorrect
Last Solution submitted on May 06, 2025

Problem Comments

Solution Comments

Show comments
PIVlab surpasses 100K all-time File Exchange downloads
During the past twelve months, PIVlab, a MATLAB Community Toolbox for particle...
4
8

Problem Recent Solvers203

Suggested Problems

Problem Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!