In Programming: Principles and Practice Using C++ (2nd Edition), there's an exercise question asking to take in a user's input and store them as int variables, and then to find the sum, product, larger, smaller and ratio of the two numbers. I can do the others perfectly fine, but I'm having trouble with the ratio. And I see that I can't use std::ratio for this, either, since it requires constant values rather than variable values.
There are also some others I don't really get how to do, so I'll ask about them here as well:
For the program that would check if a number is even or odd, should I use an if-statement that checks if a number is divisible by 2 to see if it's an even number? If so, then how do I check for odd numbers, since some odd numbers aren't even divisible by 3 anyway (otherwise it'd have made sense to divide by 3). And is it because of the division that the book says to use the modulo operator in this, is there some other reason?6 Write a program that prompts the user to enter three integer values, and then outputs the values in numerical sequence separated by commas. So, if the user enters the values 10 4 6, the output should be 4, 6, 10. If two values are the same, they should just be ordered together. So, the input 4 5 4 should give 4, 4, 5.
7 Do exercise 6, but with three string values. So, if the user enters the values Steinbeck, Hemingway, Fitzgerald, the output should be Fitzgerald, Hemingway, Steinbeck.
8 Write a program to test an integer value to determine if it is odd or even. As always, make sure your output is clear and complete. In other words, don’t just output yes or no. Your output should stand alone, like The value 4 is an even number. Hint: See the remainder (modulo) operator in §3.4.
9 Write a program that converts spelled-out numbers such as “zero” and “two” into digits, such as 0 and 2. When the user inputs a number, the program should print out the corresponding digit. Do it for the values 0, 1, 2, 3, and 4 and write out not a number I know if the user enters something that doesn’t correspond, such as stupid computer!.
And as for #10, I wonder if I only have to do it for those particular numbers (0, 1, 2, 3, and 4). And now I also that it'd have been if I'd tried to figure out better how to do this when Jumping Into C++ said to do it in one of the practice problems.
Any help anybody can provide will be much appreciated. Thanks in advance.