/* File: gym6.c Demonstrating nested loops This time the number of reps is determined by the week #. */ #include int main() { int i, j, day, week, reps ; printf("I am on a 10 week conditioning program.\n") ; printf("I will increase the # of reps as the weeks go by.\n") ; week = 1 ; while (week <= 10) { reps = 5 + week ; printf("\n------------------------------------\n") ; printf("On Week %d, I go to the gym.\n", week) ; printf("This week I will do %d reps.\n", reps) ; 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 <= reps) { 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 <= reps) { 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 ; }