/* File: gym5.c Demonstrating nested loops Added another outer loop that steps through 10 weeks. Now we have triply nested while loops. */ #include int main() { int i, j, day, week ; printf("I am on a 10 week conditioning program.\n") ; week = 1 ; while (week <= 10) { printf("\n------------------------------------\n") ; printf("On Week %d, I go to the gym.\n", week) ; day = 1 ; while (day <= 7) { printf("\n") ; if (day % 2 == 1) { printf(" Day %d: on odd days I do sit ups.\n", day) ; i = 1 ; printf(" Sit up:") ; while(i <= 10) { printf(" #%d", i) ; i = i + 1 ; } printf("\n") ; } else { printf(" Day %d: on even days I do push ups.\n", day) ; j = 1 ; printf(" Push up:") ; while(j <= 10) { printf(" #%d", j) ; j = j + 1 ; } printf("\n") ; } // end of else day = day + 1 ; } // end of while day week = week + 1; } // end of while week printf("\n------------------------------------\n") ; return 0 ; }