Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
Turbo c++(for loop)
Using (stdio.h & conio.h) header
Output:

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

What I have tried:

I tried many times to program with this output but I cant get it. I also tried to search Google for the codes or how to program it but Google doesn't seem to help me. If you have the code can I borrow it?🥹
Posted
Updated 5-May-23 12:33pm
Comments
k5054 5-May-23 11:45am    
Turbo C++ is interesting as an archaeological artifact, but otherwise should not be used. It does not support any modern (e.g. C++11 or later) C++ standards, so almost any tutorial you might google upon will not be helpful. Since Visual Studio has a free download option, I recommend that you look into that, rather than sticking with something that is obsolete.
Dave Kreskowiak 5-May-23 17:39pm    
This is a homework assignment, so switching compilers is not possible.
Patrice T 5-May-23 23:01pm    
Show your work to get explanation on what you did wrong.

While we are more than willing to help those that are stuck, that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you.

So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in!
Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did.

HAve a think about how you do it manually, and it should be pretty obvious.

If you are having problems getting started at all, then this may help: How to Write Code to Solve a Problem, A Beginner's Guide[^]
 
Share this answer
 
The task can be solved easily if you look at how you would write it down as a human.
It is best to solve it in such a way that it also works for longer outputs.
1
2 1
3 2 1
4 3 2 1
4 3 2
4 3
4

Obviously, the longest line is N characters long. Here N=4.
Now you can program a loop, which always writes a digit in front.
Since a solution with C++ is looked for, one can use here well a std::string.
The loop is run from 1 to N and in each run the loop index is written in front.
Now the string can simply be output with a newline at the end.

We will not program this for you, because it is your task and not ours.
 
Share this answer
 

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