Saturday 22 November 2014

Number Pattern in C# - 14 (FLOYED TRIANGLE)

Qus: WAP  To print Floyed triangle in c-sharp.


screenshot of floyed triangle in c-sharp
Fig: Screenshot of Output

using System;
class FloyedTriangle
{
public static void Main()
{
int i,row,j,k=1;
Console.Write("Enter the no. of row of Floyd's triangle: ");
row=Convert.ToInt32(Console.ReadLine());
for(i=1;i<=row;i++)
{
for(j=1;j<=i;j++,k++)
Console.Write("{0} ",k);
Console.WriteLine();
}
}
}