how can i get this 123456789
1234 6789
123 789
12 89
1 9
Answer / 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 |
What is the difference between int16 and int32 in c#?
What is difference between gridview and form view?
What is difference between for and foreach loop in c#?
What is boxing in c#?
What is the difference between ienumerable and iqueryable?
What is overloading in c#?
C# is case sensitive, what is mean by case sensitive
Can property be private in c#?
How to use delegates with events?
What is the diff between System.String and System.Text.StringBuilder classes?
Why main is static in c#?
What are handlers in c#?