Pages

Selasa, 03 Mei 2016

C Program to Print Triangle in Square

C# Program to Print Triangle in Square

Program Statement:
Write a program which display the following output on the screen.
####$####
###$#$###
##$###$##
#$#####$#
$#######$

Solution:
 class shape
{
int x, y;
public void sh()
{
Console.WriteLine();
for (x = 1; x <= 5; x++)
{
for (y = 1; y <= 5 - x; y++)
{
Console.Write("#");
}
Console.Write("$");
for (y = 2; y <= x * 2 - 1; y++)
{
Console.Write("#");
}
Console.Write(" $");
for (y = 1; y <= 5 - x; y++)
{
Console.Write("#");
}
Console.WriteLine(" ");
}
}
}


Related Posts by Categories

0 komentar:

Posting Komentar