A loop withing another loop is called nested loop. Consider a loop where the outer loop run 'n' time and consists of another loop inside it. The inner loop runs 'm' times. Then the total number of times the inner loop runs during program execution is m*n times.
Example: Write a C program to print the following pattern
*
**
***
****
*****
void main() { int i, j; for(i=0;i<=5;i++) { printf(“\n”); for(j=1;j<=i;j++) { printf(“*”); } } getch(); }
0 comments :
Post a Comment
Note: only a member of this blog may post a comment.