Course Web Pages

Related Links

Free eBooks


Functions

Beginning C++ Through Game Programming, by Michael Dawson.

Instructions

 instructions.cpp


Yes or No, Part 1

 yes_or_no.cpp


Yes or No, Part 2


Yes or No, Part 3

 yesornoreusable.zip


A Comparison of the Yes or No Project with Random Points


Exercises

Download instructions.cpp. Break this program into three files:

  1. A header file with the function prototype for the instructions() function.
  2. A file called main.cpp with the main() function for the program.
  3. A file called instructions.cpp with the definition of the instructions() function.

Bonus exercise

As part of the Instructions project, create two new files called formulas.cpp and a header file formuals.h. The formulas.cpp file should have a function called celsius2fahrenheit. The function should accept a float parameter and return a float. The formulas.h file should go in the include folder where instructions.h is located.

Modify main.cpp so you can use the celsius2fahrenheit function. In main.cpp, assign the results of celsius2fahrenheit(0.0f) and celsius2fahrenheit(100.0f) to a variable and print out the result.

The formula for converting Celsius into Fahrenheit is: fahrenheit = celsius * 9 / 5 + 32