how can i get this 123456789
1234 6789
123 789
12 89
1 9



how can i get this 123456789 1234 6789 123 789 ..

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

Post New Answer

More C Sharp Interview Questions

What Is The Difference Between ViewState and SessionState?

1 Answers   Fiserv,


Explain the use of Mutex in C#?

0 Answers   Sans Pareil IT Services,


How to rotate an Image in C#?

0 Answers   Petranics Solutions,


I want to single value if you give any integer value. Below are examples  1. Input: 123  Output: 6 2. Input: 99   9+9=18   1+8  Output: 9 How to get above output?

1 Answers   AxSys,


Why do we need indexers in c#?

0 Answers  






What is a nullreferenceexception and how do I fix it?

0 Answers  


How Do You Convert A Value-type To A Reference-type?

0 Answers   Siebel Systems,


What is the difference between gettype and typeof in c#?

0 Answers  


Hi Friends, I am going through Siemens Interview Procedure from last 1+1/2 months. I went through 1 written + 2 Technical + 1 Managerial Round process after which I got call from HR informing that "you are selected and we would like to meet you for HR round". HR round was very nominal compared to MR. HR Round last for hardly 5 mins. They told me that you will get the final result on Friday. Still I have not received any feedback from them. Please help!!!

0 Answers   Siemens,


destructor, Dispose, Finalize - How they relate to each other

1 Answers   Synechron,


How would you describe encapsulation in c#?

0 Answers  


What is service contract

2 Answers   Synechron,


Categories