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 a char?
What do you mean by saying a "struct is a value type"?
What are the differences between a class and a struct?
What is multicast delegate in c# ?
What is a Managed Code??
Is arraylist type safe in c#?
How can it prevents DLL Hell assembly versioning in .NET?
What is the difference between writeline and write in c#?
How to implement an object pool in c#.net.
What are partial classes and use of partial classes?
There were a lot of questions asked, so I will list the topic (and add a what is "topic" and know pros/cons). Extreme programming, what is a transaction, various SDLC design approaches, what is a namespace, define a good test case, what is a stored proc, webservice? design patterns? linker? compiler? access modifiers? stack vs. queue? arrays vs. linked lists? sorting algorithms? recursion? OOP principles?
What is polymorphism and its types in c#?
What are different types of classes in c#?
What is exe in c#?
What is different between Implicit conversion and Explicit conversion in C#?