I was able to make the Mario's pyramid from Problem Set 1, (I know it should be right alligned, not left). This is the code, and it is working fine when I execute the program, but I don't seem to understand the logic or the need of writing j <= i in the //Loop for columns.
//Loop for new row
for (int i = 0; i < n; i++)
{
//Loop for colums (#)
for (int j = 0; j <= i; j++)
{
printf("#");
}
printf("\n");
}
}
Can someone explain to me why this makes printf show 1 then 2 then 3 hashes, and so on, please? Sorry about possible english errors, my first language is Portuguese. Thanks!