|
| |||||||||||||||||||||||||||||||||||||||
| mar11 (41) | |||
|
Hi all, assuming this code:
How can i declare the variable if i want : 1- to get 90 /20 = 4.5 2- to get 90/20 = 5 thanks for each advance | |||
|
|
|||
| bluezor (298) | |
You can declare it as double a; for it to be able to take decimal points.You can round up / round down a value using <cmath>'s two functions - * ceil - http://www.cplusplus.com/reference/clibrary/cmath/ceil/ (rounding up) * floor - http://www.cplusplus.com/reference/clibrary/cmath/floor/ (rounding down) | |
|
|
|
| mar11 (41) | |
| @bluezor: thanks a lot | |
|
|
|
| firedraco (4744) | |
| Also, you need to change either 90 or 20 to a float/double (otherwise you will get 4 because of integer division). | |
|
|
|