i want to have the output :
using nested for loop.
*
**
***
**
*
without using cin.
here is my code : i think something is wrong :
#include <iostream.h>
#include <conio.h>
main()
{
int i, j;
for (i = 1; i <= 5; i++)
{
cout << "*" << "\n";
{
for (j = 1; j < i; j--)
{
cout << "*" << "\n";
}
}
}
getch();
}
Take a look at your inner loop. On the second time around you're saying:
For (set j to 1; do while j < 2; each time around j = j - 1)
which will continue on forever.