when user types number X, outputs a pyramid of size of X
if X is 6,
*
**
***
****
*****
******
using System;
class example4
{
public static void Main()
{
{
public static void Main()
{
int i;
int j;
int k;
Console.WriteLine("type number of size");
int j;
int k;
Console.WriteLine("type number of size");
object a = (object)Console.Read();
int b = (int) a;
for (i = 0; i <= b;i++)
{
for (j = 0; j < b+1-i;j++)
{
{
Console.Write("");
}
for (k = 0; k < i; k++)
{
Console.Write("*");
Console.Write("*");
}
Console.WriteLine("\n");
}
}
}
}
but this doesn`t work
how should I solve that problem?
Bing InPosted Apr 4, 2016, 3:39 AM
Shubham KumarPosted Apr 3, 2016, 8:26 AM
public class example4
{
public static void Main()
{
int i;
int j;
int k;
Console.WriteLine("type number of size");
int a = int.Parse(Console.ReadLine());
int b = (int) a;
for (i = 0; i <= b;i++)
{
for (j = 0; j < b+1-i;j++)
{
Console.Write("");
}
for (k = 0; k < i; k++)
{
Console.Write("*");
}
Console.WriteLine("\n");
}
}
}