a) 1
2 3
4 5 6
7 8 9 10
Source code:
using System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
namespace pyramid1
{
class pyramidd
{
public void pyramid1()
{
int
n;
int
i, c;
int
a=1;
Console.Write("Enter the number of rows of Floyd's triangle to
print\n");
n = int.Parse(Console.ReadLine());
for
(i = 1; i <= n; i++)
{
for
(c = 1; c <= i; c++)
{
Console.Write(" "+a);
a++;
}
Console.Write("\n");
}
Console.Read();
}
}
class Program
{
static void Main(string[]
args)
{
pyramidd
p = new pyramidd();
p.pyramid1();
}
}
}
No comments:
Write comments