Click here to Skip to main content
14,332,142 members
Rate this:
Please Sign up or sign in to vote.
See more:
I am preparing for my interview so could you please tell me how do i print this in c#

1
1 2 1
1 2 3 2 1
1 2 3 4 3 2 1
1 2 3 4 5 4 3 2 1

please tell me ASAP.....
Thanks in advance....
Posted
Updated 13-Jul-19 18:09pm
Rate this:
Please Sign up or sign in to vote.

Solution 2

Try:
Console.WriteLine("1");
Console.WriteLine("1 2 1");
Console.WriteLine("1 2 3 2 1");
Console.WriteLine("1 2 3 4 3 2 1");
Console.WriteLine("1 2 3 4 5 4 3 2 1");

If you mean "Please write the code to do this dynamically so I get a job I don't deserve and can't do", then I really think you should write it yourself, as if you can't I for one do not want to work next to you!
   
Rate this:
Please Sign up or sign in to vote.

Solution 1

A for loop[^] along with string concatenation[^] should act as a hint for you to proceed further.
   
Comments
OriginalGriff 25-Jan-13 4:18am
   
You do need three loops (or two and an insert as well as a concatenation) to do the "up then down".
But it's, what? Six lines of C# plus curly brackets if you do it with Console.Write?
If he can't do that...:sigh:

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100