Modify the while loop to utilize tolower() or toupper(). Add default values to the to_celsius() and to_fahrenheit() functions. Use the temperature when water freezes! CLARIFICATION: Only put the default value in the declaration of the function at the top of the program and NOT in the actual function below. Example of code in the declaration section above main(): double to_celsius(double fahrenheit = 32.0); Add two more functions to handle another type of conversion (distance, weight, etc.) and use function overloading. Overload the functions with double and int data types. Example (requiring four new functions): Kilograms to Pounds (using double) Pounds to Kilograms (using double) Kilograms to Pounds (using int) Pounds to Kilograms (using int) You could use miles to kilometers, etc. Add the factorial function that works by using recursion.
-
- Modify the while loop to utilize tolower() or toupper().
-
- Add default values to the to_celsius() and to_fahrenheit() functions.
-
Use the temperature when water freezes!
- CLARIFICATION: Only put the default value in the declaration of the function at the top of the program and NOT in the actual function below.
- Example of code in the declaration section above main():
- CLARIFICATION: Only put the default value in the declaration of the function at the top of the program and NOT in the actual function below.
-
- Add default values to the to_celsius() and to_fahrenheit() functions.
double to_celsius(double fahrenheit = 32.0);
-
- Add two more functions to handle another type of conversion (distance, weight, etc.) and use function overloading.
-
Overload the functions with double and int data types.
- Example (requiring four new functions):
- Kilograms to Pounds (using double)
- Pounds to Kilograms (using double)
- Kilograms to Pounds (using int)
- Pounds to Kilograms (using int)
- You could use miles to kilometers, etc.
-
- Add two more functions to handle another type of conversion (distance, weight, etc.) and use function overloading.
-
- Add the factorial function that works by using recursion.
- Example code given in class:
- Add the factorial function that works by using recursion.
/*
Recursion Example
--Calculating a factorial
Factorial of 5 = 1 * 2 * 3 * 4 * 5 = 120
Need a function that "recursively" calls itself.
Need a function that has a limiting point when recursion stops.
*/
#include <iostream>
using namespace std;
int factorial(int n);
int main()
{
const int limit = 5;
int fact = factorial(limit);
cout << "Factorial of " << limit << " is: " << fact << endl;
return 0;
}
int factorial(int n)
{
if (n < 0) return(-1); // negative number out of bounds, leave function
if (n == 0) return(1); // 0 means finished, leave function
else
{
return (n * factorial(n - 1)); // recursive call
}
}
-
- Write excellent comments:
- At the top to show your name, the class, and what the program does.
- For each function.
- Critical or tricky parts that might be difficult to understand without a comment.
- Write excellent comments:
Step by step
Solved in 2 steps with 2 images