Presentation is loading. Please wait.

Presentation is loading. Please wait.

Nested Loops. Problem Print The only printfs you can use are: –printf(“*”); –printf(“\n”); *****

Similar presentations


Presentation on theme: "Nested Loops. Problem Print The only printfs you can use are: –printf(“*”); –printf(“\n”); *****"— Presentation transcript:

1 Nested Loops

2 Problem Print The only printfs you can use are: –printf(“*”); –printf(“\n”); *****

3 Nested Loops //print a rectangle of stars for(i = 0; i < 3; i++) { //print a line of stars }

4 Nested Loops //print a rectangle of stars for(i = 0; i < 3; i++) { //print a line of stars } //print a line of stars for(i = 0; i < 5; i++) { //print one star printf(“*”); }

5 Nested Loops //print a rectangle of stars for(i = 0; i < 3; i++) { //print a line of stars for(i = 0; i < 5; i++) //IS THIS OKAY? { //print one star printf(“*”); }

6 Okay now? //print a rectangle of stars for(i = 0; i < 3; i++) { //print a line of stars for(j = 0; j < 5; j++) { //print one star printf(“*”); }

7 Okay now? //print a rectangle of stars for(i = 0; i < 3; i++) { //print a line of stars for(j = 0; j < 5; j++) { //print one star printf(“*”); } printf(“\n”); }

8 Problem Design a program which prompts the user for a number of rows between 0 and 10 and prints the following pattern: ** *** **** …


Download ppt "Nested Loops. Problem Print The only printfs you can use are: –printf(“*”); –printf(“\n”); *****"

Similar presentations


Ads by Google