Hi,
Your both codes are wrong.
void main()
{
for(int i=1; i<=5; ++i)
{
for(int j=1; j<=i; ++j)
cout<<j<<"";
cout<<'\n';
}
}
In the second for loop the condition should include "i" not "1".
Here the forst loop goes on and in the 2nd loop the values get printed as 1.
In the 2nd iteration the value of i=2.
So it will print 12.
like wise it will go on printing till the outer loop condition satisfies.
If you can able to learn dry run then it would help you in developing logic. its not advisable to get help every time from such forums.
Thanks,
Sisir Patro