how can i get this 123456789
1234 6789
123 789
12 89
1 9

Answer Posted / tanvir anwar

int n = 9; // you can use any odd number for similar pattern
int mid = (n+1)/2;
for (int i = 0; i < mid; i++)
{
for (int j = 1; j <= n; j++)
{
if (j <= mid-i || j >= mid+i)
Console.Write({0}, j);
else
Console.Write(" ");
}
Console.WriteLine();
}

Is This Answer Correct ?    10 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the principles of delegation?

496


In .NET which is the smallest unit of execution?

647


Is c# slower than java?

488


Can abstract class have constructor?

506


How does substring work in c#?

488






What is using in c#?

475


What does mean before a string in c#?

528


What is the difference between writeline and write in c#?

437


Does c# support multiple class inheritance?

612


Can an abstract class have a constructor c#?

495


Which attribute is used in order that the method can be used as webservice?

520


How is the syntax written to inherit from a class in C#?Give an example ?

554


What is boxing and unboxing in c#?

480


How Global.asax is used ?

617


Can constructor be protected in c#?

508