Program:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
public class Class2
{
static void Main(string[] args)
{
int x, i, j;
Console.WriteLine("enter the value :");
x = int.Parse(Console.ReadLine());
for (i = 1; i <= x; i++)
{
for (j = 1; j <= i; j++)
{
Console.Write("* ");
}
Console.WriteLine();
}
Console.ReadLine();
}
}
}
Explanation:
Here in the above example the two for loops are used for displaying as per the format shown in the output. vaariables x,i and j are used according to the requirement. On execution of inner loop star/stars are displayed. To display them in different lines second WriteLine() method statement is used.
output:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
public class Class2
{
static void Main(string[] args)
{
int x, i, j;
Console.WriteLine("enter the value :");
x = int.Parse(Console.ReadLine());
for (i = 1; i <= x; i++)
{
for (j = 1; j <= i; j++)
{
Console.Write("* ");
}
Console.WriteLine();
}
Console.ReadLine();
}
}
}
Explanation:
Here in the above example the two for loops are used for displaying as per the format shown in the output. vaariables x,i and j are used according to the requirement. On execution of inner loop star/stars are displayed. To display them in different lines second WriteLine() method statement is used.
output:
very thanks
ReplyDelete