hello friends,
I want to print Pyramid in C# using * .. if you have any
idea how can i make it then please help me i need your help...
Thanks In Advance
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
PJ MartinsPosted May 28, 2010, 11:08 AM
// number of rows you wish to print
int rows = 10;
// variable to store number of stars to print
string rowPrint = string.Empty;
for (int i = 1; i <= rows; i++)
{
int numStars = 2 * i - 1;
rowPrint = string.Empty;
for (int j = 1; j <= numStars; j++)
rowPrint += "*";
Console.WriteLine(rowPrint.PadLeft(rows + i, ' '));
}