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
What are the principles of delegation?
In .NET which is the smallest unit of execution?
Is c# slower than java?
Can abstract class have constructor?
How does substring work in c#?
What is using in c#?
What does mean before a string in c#?
What is the difference between writeline and write in c#?
Does c# support multiple class inheritance?
Can an abstract class have a constructor c#?
Which attribute is used in order that the method can be used as webservice?
How is the syntax written to inherit from a class in C#?Give an example ?
What is boxing and unboxing in c#?
How Global.asax is used ?
Can constructor be protected in c#?