C++
# include
# include
void main()
{
int height;
char design;
cout<"enter pyramid height";
cin>>height;
cout<<"enter pyramid design";
cin>>design>>endl;
for (int i = 0; i < height; i++)
{
for (int k = i; k < height; k++)
{
cout<<" ";
}
for (int j = 2 * i + 1; j > 0; j--)
{
cout<< design
}
cout<<""<< endl
}
getch();
}
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Pyramid
{
class Program
{
static void Main(string[] args)
{
int height;
char design;
Console.Write("enter pyramid height ");
height = int.Parse(Console.ReadLine());
Console.WriteLine("");
Console.WriteLine("");
Console.Write("enter pyramid design ");
design = char.Parse(Console.ReadLine());
Console.WriteLine("");
Console.WriteLine("");
for (int i = 0; i < height; i++)
{
for (int k = i; k < height; k++)
{
Console.Write(" ");
}
for (int j = 2 * i + 1; j > 0; j--)
{
Console.Write(design);
}
Console.WriteLine("");
}
Console.ReadLine();
}
}
}
Share this page on
0
People Like(s) This Page
Permalink
comments powered by Disqus