Challenges

Remember the rules for this are

  • Try to use only the information given up to this point in this book.
  • Try not to give up until you've given it a solid attempt

You are extremely likely to be quizzed on for loops on any standardized tests, so these challenges are going to include a lot of repetition and sometimes a tricky case to handle. Its for your own good, I hope.

Challenge 1

Write code that will output every number from 0 to 15, including 0 and 15.

0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
void main() {

}

Do it using a for loop and again using a while loop.

Challenge 2

Write code that will output every number from 15 to 0, including 0 and 15.

15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
0

Do it using a for loop and again using a while loop.

void main() {

}

Challenge 3

Write code that will output every number from 15 to 0, excluding 0 and 15.

14
13
12
11
10
9
8
7
6
5
4
3
2
1

Do it using a for loop and again using a while loop.

void main() {

}

Challenge 4.

Write code that will output every third number from 51 to 66.

53
56
59
62
65

Do it using a for loop and again using a while loop.

void main() {

}

Challenge 5.

Draw a square.

Make it so that you can make the square bigger or smaller by changing a variable at the start of the program.

*****
*****
*****
*****
void main() {

}

Challenge 6.

Draw a rectangle.

Make it so that you can make the rectangle bigger or smaller in either dimension by changing a variable at the start of the program.

******
******
******
void main() {

}

Challenge 7.

Draw a circle!

Make it so that you can make the circle bigger or smaller by changing a variable at the start of the program.

    **
   ****
  ******
 ********
  ******
   ****
    **
void main() {

}

Challenge 8.

Draw a smiley face!

Make it so that you can make the smile bigger or smaller by changing a variable at the start of the program.

void main() {

}