using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication3
{
class PrintABCDE
{
static void Main()
{
string Stroutput = string.Empty;
Console.WriteLine("Enter any number between 1 and 26");
int UserNumber = int.Parse(Console.ReadLine());
if (UserNumber >= 1 && UserNumber <= 26)
{
char[] alpha = Enumerable.Range('A', UserNumber).Select(i => (Char)i).ToArray();
for (int i = 0; i < UserNumber; i++)
{
for (int y = 0; y <= i; y++)
{
Stroutput = string.Format(Stroutput + alpha[y] + " ");
}
Stroutput = Stroutput.Remove(Stroutput.Length - 1);
if (i == UserNumber - 1)
{
Console.Write(Stroutput);
Stroutput = string.Empty;
}
else
{
Console.WriteLine(Stroutput);
Stroutput = string.Empty;
}
}
}
else
{
Console.WriteLine("Number entered is not in Given Range");
}
Console.Read();
}
}
}
Output 1 :
Output 2 :
No comments:
Post a Comment