#include<stdio.h>
int main ( void ){
int row;
int column;
for ( row = 1; row <= 7; row++ ){
for (column = 1; column <= row; column++ )
printf("*");
printf("\n");
} printf("\n");
}
I want to know if loop is can be used without {
after its argument?
Is it possible to translate this code for me? I see the loop coming out of the first for
, checking the condition of the second and giving print after that it will add in column
and return to add in row
also, and getting row = 2
and column = 2
, this way it will give another print .
The problem is that if so, this second loop would no longer be in accordance with the figure since printf
is only triggered when column <= row
.
How does this snippet work?
The program starts and releases * as output because column <= row = TRUE
(both are 1), then 1 is added to column
, making column < = row = FALSE
program exits the internal loop and skips a line, adding 1 to row and making column (2) <= row(2) = TRUE
again, because of this the program will release one more * on the line below and then of this will add +1 to column
and make olumn(3) <= row(2) = FALSE
, causing it to exit the internal loop and go to the outer loop.
With this in mind I'm imagining that a vertical row will be formed from * since column
is only -1 that row
, always, when that -1 ceases to exist with