Write a program that displays the following output on the screen.
####$####
###$#$###
##$###$##
#$#####$#
$#######$
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Problem29
{
classProblem29
{
staticvoid Main(string[] args)
{
Console.WriteLine("\t\tName: Ehtesham Mehmood\n\t\tRoll No: 11014119-131\n\t\tSection: AE\n \t\t UOG\n");
int firstdollar = 8;
int seconddollar;
int k;
int x = 8;
int space = 0; int val;
int j;
int i = 1;
while (i <= 5)
{
j = 4;
val = x;
seconddollar = val;
while (j <= val) //This loop is for left side triangle
{
if (j == firstdollar)
{
Console.Write("$");
}
else
Console.Write("#");
j++;
}
if (i == 1)
val--;
k = 1;
while (k <= space) //This loop is for center triangle
{
Console.Write("#");
k++;
}
space = 2 * i - 1;
while (val >= 4) //This loop is for right side triangle
{
if (val == seconddollar)
{
Console.Write("$");
}
else
{
Console.Write("#");
}
val--;
}
i++;
x--;
firstdollar--;
Console.WriteLine();
}
Console.ReadKey();
}
}
}
output