More Loops

  • These first few are from chapter 3, but we skipped them.
  • size_t find(string pattern [, size_t pos=0]
  • Write a program to find the number of times a word occurs in a string. (i.e. how many times does "Dan" appear in "Danger, Danger, Danger!"
  • string substr(size_t pos, size_t lend)
  • And a non-string function or two.
  • Write a program that prints 5 random numbers between 1 and 6 (rolls a six sided die five times)
  • Write a program that emulates a magic 8 ball. The user types a question, the magic 8 ball repeats the question and provides an answer.