13. Example:- nested while loops #include<stdio.h> #include<conio.h> main() { int r=1,c=1; while (r<=5) { c=1; while(c<=r) { printf(“%d”,c); c++; } printf(“”); r++; } getch(); }
14.
15. Starts with a do statement and then tests the repetition condition in the while statement at the end of the loop. Syntax:- do { statements; } while(condition);
16. The while Loop condition evaluated true false statement Logic of a do….while loops
17. Example:- do….While loop Accept any number from the user to print the number is positive or negative. #include<stdio.h> #include<conio.h> main() { int a; do { printf(“Enter any number”); scanf(“%”,&a); if (a>=0) printf(“Number is positive”); else printf(“Number is Negative”); } while(a!=0); getch(); }
18.
19.
20. Example:- nested for loops #include<stdio.h> #include<conio.h> main() { intr,c,k=1; for (r=1;r<=4;r++) { for (c=1;c<=r; c++) { printf(“%d”,k); k++; } printf(“”); } getch(); }