Below is the screenshot of the code in which I have made a pyramidwritten the following program. My question is in C# to display an ASCII pyramid. Is it a good code from the performance point of view or not?
public static void method1()
{
int k;
int kCond = 5;
int i;
int inc = 0;
for (int p = 0; p <=5; p++)
{
for(k = 0; k <= kCond; k++)
{
Console.Write(" ");
}
kCond--;
for(i=0; i<=inc; i++)
{
Console.Write("*")
}
inc +=2;
Console.WriteLine();
}
}
Output:
*
***
*****
*******
*********
***********
My question is, is this good code from a performance point of view, or not? How could I improve it?