HOW TO PRINT DIAMOND SHAPE WITH STARS IN C SHARP ?
DESCRIPTION:
IN THIS I AM GOING TO SHOW HOW TO DISPLAY DIAMOND SHAPE IN CONSOLE APPLICATION WITH STARS IN C#
OPEN CONSOLE APPLICATION
(Program.cs)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DIMOND
{
class Program
{
static void Main(string[] args)
{
int i, j, n;
Console.WriteLine("Enter
no for printing star in diamond shape");
n
= int.Parse(Console.ReadLine());
for (i = 1; i <= n; i++)
{
for (j = n; j >= i; j--)
{
Console.Write(" ");
}
for (j = 1; j <= i; j++)
{
Console.Write("*");
}
for (j = 1; j <= i; j++)
{
Console.Write("*");
}
Console.WriteLine();
}
for (i = 1; i <= n; i++)
{
for (j = 0; j <= i; j++)
{
Console.Write(" ");
}
for (j = n; j >= i; j--)
{
Console.Write("*");
}
for (j = n; j >= i; j--)
{
Console.Write("*");
}
Console.WriteLine();
}
Console.ReadKey();
}
}
}
OUTPUT:
Hey its very amazing i was trying from last two months i was not getting this thank u for giving this code.
ReplyDeleteFor similar type of c# interview questions i can prefer you to visit this link also
c# interview questions
Thanx
ReplyDeleteIf you have any doubts in .net you comment here i will clarify that doubts
DeleteThis comment has been removed by the author.
DeleteI really appreciate information shared above. It’s of great help. If someone want to learn Online (Virtual) instructor lead live training in C SHARP, kindly contact us http://www.maxmunus.com/contact
ReplyDeleteMaxMunus Offer World Class Virtual Instructor led training on C SHARP. We have industry expert trainer. We provide Training Material and Software Support. MaxMunus has successfully conducted 100000+ trainings in India, USA, UK, Australlia, Switzerland, Qatar, Saudi Arabia, Bangladesh, Bahrain and UAE etc.
For Demo Contact us.
Nitesh Kumar
MaxMunus
E-mail: nitesh@maxmunus.com
Skype id: nitesh_maxmunus
Ph:(+91) 8553912023
http://www.maxmunus.com/