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 is asynchronous one-way calls?

525


What is boxing & unboxing?

572


Define Abstract Class in C#

546


What is the purpose of namespace in c#?

448


What is difference between constants and readonly in c#?

488






what is full assembly reference

512


What are the classes contained in a single .NET DLL ?

508


What is the wildcard character in sql?

520


How does yield return work c#?

509


What are anonymous types in c#?

477


What is linq c#?

504


What is function c#?

492


What is default value of decimal c#?

477


Is it possible to inherit multiple interfaces?

542


State the top.NET class that everything is derived from?

525