/* File: gym4.c Demonstrating nested loops Nested loops. Alternate between sit ups & push ups. */ #include int main() { int i, j, day ; printf("This week I go to the gym\n") ; 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 return 0 ; }