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
Is as keyword in c#?
What is action c#?
Can we make a class private in c#?
How do generics work in c#?
Is c sharp free?
Can you describe iuknown interface in short?
What is the difference between interface and abstract class in c#?
Are string objects mutable or immutable?
What is platform independence"?
What is a private class in c#?
How do I do implement a trace and assert?
Can you instantiate a struct without using a new operator in c#?
Why delegates are safe in c#?
What is ado net in c#?
Can struct be static in c#?