/* File: gym7.c Demonstrating nested loops This time, we use for loops */ #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") ; for (week = 1 ; week <= 10 ; week++) { 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) ; for (day = 1 ; day <= 7 ; day++) { printf("\n") ; if (day % 2 == 1) { printf(" Day %d: on odd days I do sit ups.\n", day) ; printf(" Sit up:") ; for (i = 1 ; i <= reps ; i++) { printf(" #%d", i) ; } printf("\n") ; } else { printf(" Day %d: on even days I do push ups.\n", day) ; printf(" Push up:") ; for (j = 1 ; j <= reps ; j++) { printf(" #%d", j) ; } printf("\n") ; } // end of else } // end of for (day ... } // end of for (week ... printf("\n------------------------------------\n") ; return 0 ; }