Click here to Skip to main content
16,018,264 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
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

Try:
C#
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!
 
Share this answer
 
A for loop[^] along with string concatenation[^] should act as a hint for you to proceed further.
 
Share this answer
 
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, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900