C# Program to Print Triangle in Square
Program Statement:
Program Statement:
Write a program which display the following output on the screen.
####$####
###$#$###
##$###$##
#$#####$#
$#######$
Solution:
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("\b$");
for (y = 1; y <= 5 - x; y++)
{
Console.Write("#");
}
Console.WriteLine("\n");
}
}
}
This is an interesting post, good job and thanks for sharing. I'd like to share the following profile with you about CPS - clicks per second. It can be used in your spare time as a game. It's a really useful tool.
BalasHapus