+ 1
Can you please explain the output of this code?
2 Respuestas
+ 1
#include <stdio.h>
void main()
{
int i,j;
// First loop, loops the second(nested) loop 10x
for (i=0;i<10;i++) {
//second(nested) loop, loops 10x
for (j=10;j>0;j--) {
// print till j==i and breaks the loops
printf("*");
// i counts positive
// j counts negative
// j == i = 50 (break loop at half of 100 since the first loop counts positive and second(nested) loop counts negative which results 50 from the original 100)
// output is 50 + 1 = 51 x * will be printed
if (j==i+1) break;
}
}
}
Hope I'll explained it well👍
0
🌴Vincent Berger🌴 you are wrong! This code will print 10+9+8+7+6+5+4+3+2+1=55 stars (*)