Hi Coders,
When i was in my college days, i have faced this situation multiple time that we have to write a program to print * half pyramid. So i am explaining code here.
Hope this will help you out:
Output:
The code snippet for this output is :
The Source code is : You need to open new project -> Console application -> Name it.
In that project there will be a program.cs file where you can replace the code and see the output
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int i, j, rows;
Console.Write("Enter the number of rows: ");
rows = Convert.ToInt32(Console.ReadLine());
for (i = 1; i <= rows; ++i)
{
for (j = 1; j <= i; ++j)
{
Console.Write("* ");
}
Console.Write("\n");
}
Console.ReadLine();
}
}
}
Happy Coding :)
When i was in my college days, i have faced this situation multiple time that we have to write a program to print * half pyramid. So i am explaining code here.
Hope this will help you out:
Output:
The code snippet for this output is :
The Source code is : You need to open new project -> Console application -> Name it.
In that project there will be a program.cs file where you can replace the code and see the output
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int i, j, rows;
Console.Write("Enter the number of rows: ");
rows = Convert.ToInt32(Console.ReadLine());
for (i = 1; i <= rows; ++i)
{
for (j = 1; j <= i; ++j)
{
Console.Write("* ");
}
Console.Write("\n");
}
Console.ReadLine();
}
}
}
Happy Coding :)
Checkit out
ReplyDelete