We are providing online training of realtime Live project on Asp.Net MVC with Angular and Web API. For more information click here. If you have any query then drop the messase in CONTACT FORM

Sunday, June 7, 2015


-> Write a program of diamond pattern is using with three loops?

class Program


{ 
static void Main(string[] args)

{
int val=0;

int temp=0;

Console.WriteLine("Enter the input number");

int n = int.Parse(Console.ReadLine());

for (int row = 0; row < (2 * n - 1); row++)

if (row <= (n - 1))

{ for(int space=0;space<n+row;space++)
if (space< (n - row) - 1)

{
Console.Write(" ");

}
else

{
Console.Write("*");

} Console.WriteLine();

}
 
else

{
 
temp += 2;

val++;
for (int coll = 0; coll < (row+n)-temp; coll++)

if (coll < val)


{
 
Console.Write(" ");

}
else
{

Console.Write("*");


} 
Console.WriteLine();


} 
Console.WriteLine();

Console.ReadLine();

}

}
 
 OUTPUT:
 



No comments: