| myka316 (11) | |
| Is there a way to take numbers after a decimal and put them into a completely new category? (i.e. the conversion of feet to meters. Typically it would result in (feet * .3048) => (4 * .3048) = 1.2192 or 1 meter 21.91 centimeters), Is there a way to tell my program to assign the "1" to meters and place the "21.91" in a centimeters column that I create? | |
|
Last edited on
|
|
| Chervil (812) | ||||
Output:
If cm is of type double instead of int, you can keep the millimetres too. | ||||
|
Last edited on
|
||||
| myka316 (11) | |||
|
Thank you very much for the response Chervil. Is there a way for me to create a function that will utilize that formula? Would something like this work?
I'm basically trying to allow a user to input a number for feet/inches to be converted to meters/cm. My current coding allows for a user to get the calculations but will not convert the numbers following the decimal in "feet" to centimeters. | |||
|
Last edited on
|
|||
| Chervil (812) | |
|
I would place the value 0.3048 inside the function. No point passing it as a parameter, the value won't change. As it stands, your function doesn't return any results at all. See the tutorial for how to return one or several values. The first page covers the basics while the second describes passing by reference which is what you need for returning two or more values. http://www.cplusplus.com/doc/tutorial/functions/ http://www.cplusplus.com/doc/tutorial/functions2/ | |
|
Last edited on
|
|