code for making different types of starformat on traingle form...
iam new to console application help me to create starformat on different traingle shapes
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Raja TRank #685 · 3.5K reputationPosted Jul 23, 2015, 9:41 PM EDT
/*
* C# Program to Display Numbers in the form of Triangle
*/
using System;
class Pascal
{
public static void Main()
{
int[,] arr = new int[8, 8];
for (int i = 0; i < 8; i++)
{
for (int k = 7; k > i; k--)
{ //For loop to print spaces
Console.Write(" ");
}
for (int j = 0; j < i; j++)
{
if (j == 0 || i == j)
{
arr[i, j] = 1;
}
else
{
arr[i, j] = arr[i - 1, j] + arr[i - 1, j - 1];
}
Console.Write(arr[i, j] + " ");
}
Console.WriteLine();
}
Console.ReadLine();
}
}
More details check out
http://www.sanfoundry.com/csharp-program-numbers-triangle/
Ashwani Chaudhary171 reputationPosted Jul 23, 2015, 10:32 PM EDT
namespace ConsoleApplication20
{
class Program
{
static void Main(string[] args)
{
int count = 1;
for (int i = 0; i <5; i++)
{
for (int j = 5; j >= i; j--)
{
if (i >= j)
{
for (int b = 1; b <= count; b++)
{
Console.Write("*");
}
count++;
}
else
{
Console.Write(" ");
}
}
for (int k = 1; k <= 5; k++)
{
if (i < k)
Console.Write(" ");
else
Console.Write("*");
}
Console.WriteLine();
}
Console.ReadKey();
}
}
}
Munesh SharmaRank #174 · 13.9K reputationPosted Jul 23, 2015, 10:36 PM EDT
namespace Triangle
{
class Program
{
static void Main(string[] args)
{
int i, j,m,k=6;
Console.WriteLine();
for (i = 1; i <= 5; i++)
{
for (m = 1; m <= k; m++)
{
Console.Write(" ");
}
for (j = 1; j <= i; j++)
{
Console.Write(" " + "*");
}
for (j = i-1; j >= 1; j--)
{
Console.Write(" " + "*");
}
k--;
Console.WriteLine();
}
Console.Read();
}
}
}
Sample Output
*
* * *
* * * * *
* * * * * * *
* * * * * * * * *
Munesh SharmaRank #174 · 13.9K reputationPosted Jul 23, 2015, 10:37 PM EDT