Meeting 3 pre-work

This week's pre-work is largely reading and small coding exercises. Please spend at most 2 hours on it.

Please don't hesitate to email me for help with questions or code before our next class. I am also frequently on Google Hangouts -- try chatting with me for faster response.

All readings are from Programming in C, Fourth Edition by Stephen G. Kochan
  • Read Chapter 4: Program Looping (pgs 43-63). Problem set 1 requires good use of looping in several places, so it's important to be very comfortable with this idea and how to use it. You might also review the Loops video from last week's pre-work.

  • Do these practice exercises on Cloud 9 (the CS50 IDE). Send me an email with the code for each program you complete. Try doing it yourself before looking at the solution. Re-read the book, look at the videos from last week. Then look at the solution if you are still stuck. If you do get something working, look at the solution to compare yours with it.

    • Write a short program that prints your name to the screen 20 times. Use a loop. Solution
    • Write a short program that prints out the numbers from 1 to 10. Use a loop. Solution
    • Write a short program that prints out the even numbers between 27 and 63. Use a loop. Solution
    • Write a short program that asks the user for an integer (use GetInt() from the CS50 library), and then prints "Hello" to the screen that number of times. Use a loop. Solution
    • Write a short program that generates a multiplication table for all single-digit pairs (1x1 up through 9x9). The output format is up to you. Use a nested loop. Solution

  • Read part of Chapter 7: Working with Functions (pgs 119-130).

  • Do these practice exercises on Cloud 9 (the CS50 IDE). Send me an email with the code for each program you complete.
    • Write a short program that asks the user if they would like to (1) see 20 copies of your name, (2) see the numbers from 1 to 10, or (3) see a multiplication table. Use GetInt() to get their answer, then do the selected task. This program is simply three of the exercises above, with a user selection layered on top. Put the code for each of the choices into its own function. So your final code must have three functions in it: ShowMyName(), CountToTen(), and PrintMultiplicationTable(). The selector code can live in the main() function, and call one of these. Solution