^^^^Code:#include<stdio.h> int main(void ) { for (int b=0;b<=5;b++) for (int a=0;a<=b;a++) printf("*\n"); }
I dont know why this code executes 21 "*" line by line
I mean why it prints 21 particular ?
thank you
^^^^Code:#include<stdio.h> int main(void ) { for (int b=0;b<=5;b++) for (int a=0;a<=b;a++) printf("*\n"); }
I dont know why this code executes 21 "*" line by line
I mean why it prints 21 particular ?
thank you
Because:
In other words, trace the flow of control, watch the variables (e.g., using a debugger), and it will soon become clear to you.Code:#include<stdio.h> int main(void) { for (int b = 0; b <= 5; b++) for (int a = 0; a <= b; a++) printf("b=%d, a=%d\n", b, a); }
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
Thank you so much I got it