b) 1
2 3 4
5 6
7 8 9
Source code:
using System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
namespace pyramid1
{
class pyramidd
{
public void pyramid1()
{
int
no;
int
rw;
int
c;
int
spc;
Console.WriteLine("Enter number of rows : ");
no= int.Parse(Console.ReadLine());
for
(rw = 1; rw <= no; rw++)
{
for
(spc = no; spc >= rw; spc--)
{
Console.Write(" ");
}
for
(c = 1; c <= rw; c++)
{
Console.Write(" " +c);
}
Console.Write("\n");
}
Console.Read();
}
}
class Program
{
static void Main(string[]
args)
{
pyramidd
p = new pyramidd();
p.pyramid1();
}
}
}
No comments:
Write comments