Here is your code written in correct C++.
printf is to be avoided; in the future please consider using
cout.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
#include <cstdio>
using namespace std;
int main()
{
int i,j;
for(i=5;i>=1;i--)
{
for(j=5;j>=i;j--)
{
printf("%d",j);
printf("\n");
}
}
}
|
Here is a test run:
http://ideone.com/usz0y
The only value ever output is j. Each time through the loop, j starts at five and counts down until it is lower than i, and then i is lowered and the loop goes round again.
So the first time, i is 5, so output j is 5.
Next time, i is 4, so output j is 5 and then 4.
Next time, i is 3, so output j is 5 then 4 then 3.
etc etc.
My usual comments here apply; Turbo C++ is twenty years old, it's not C++, you're learning something that isn't C++ and would be rejected by a C++ compiler, please stop using old tools when you could be using new, correct tools for free.
If this tool is mandated by your school, consider complaining to the school that you're paying a fortune to be educated and they're wasting your time and money by teaching this.