Previous section To contents

3.4 Exercises

  • End all functions in the examples in chapter two with a return statement.
  • Change all foreach loops to for or while loops.
  • Make the find_song function in chapter 2 return when the first matching song is found.
  • Make the find_song function write the number of the record the song is on.
  • If you failed to get the program to work properly in the last exercise of chapter 2, try it again now.
  • Make a program that writes all the numbers from 1 to 1000.
  • Modify the program in the previous exercise to NOT write numbers divisible by 3, 7 or 17.
  • Make a program that writes all the prime numbers between 1 and 1000.

  • Previous section To contents