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

Is as keyword in c#?

515


What is action c#?

486


Can we make a class private in c#?

498


How do generics work in c#?

482


Is c sharp free?

538






Can you describe iuknown interface in short?

615


What is the difference between interface and abstract class in c#?

459


Are string objects mutable or immutable?

526


What is platform independence"?

537


What is a private class in c#?

491


How do I do implement a trace and assert?

558


Can you instantiate a struct without using a new operator in c#?

530


Why delegates are safe in c#?

451


What is ado net in c#?

499


Can struct be static in c#?

506