concentrate on this piece of code
for (i = 0; i <= 5 ;i++) {
--> for (space = 5 - i; space <= 4; space++) {
printf(" ");
}
in first iteration of inner for loop space value is space: 5-0 = 5
as the i:0
and for we have condition space <= 4
and this not satisfy control does not
go in to the inner of for braces and not print any space (for first row)
you must know how the for(;;)
works.
for (i=0 ; i<10 ; i++ ) {
printf("%d",i);
}
// end loop line
for (loop index initialize ; condition ; do after innerloop commands ) {
command1;
command2;
}
first of all i:0
and because i
is less than 10 inner of loop executes
and print 0 on screen.
after printing i
are incremented by one (i++
equals to i = i+1
).
then i:1
, i
still less than 10 and print i:1
, wee see 1 on screen and so
on. until we have i:9
print 9 on screen then increase by one i:10
then last iteration come, as now i:10
and is not less than 10 the inner of
loop not execute, program control comes to after loop (end loop line).
solved Please Explain me this C code [closed]