![]() |
Creating a program that roundup
I have created a program that should roundup a number:
Code:
#include <iostream> |
Re: Creating a program that roundup
The answer will ether be the 0 or 1. So what i think is happening is in the first IF, when it says cout<<numroundup1; it is printing 1, and that is because its value is 1. Back at the start of your program when you declare numroundup1 and you've got "= numr + 1" more or less since that at that time numr's value is 0 it really looks like this "int numroundup1 = 0 + 1" which will result in you getting 1 as the answer. What I think would be better is this:
Code:
#include <iostream> |
Re: Creating a program that roundup
Thank you very much. Tell me if I am wrong but when I say .5 it means whatever number.5
|
Re: Creating a program that roundup
Actually you are right. If its more than .5 it enters the if statement. Is there a way a could fix this?
Thank You, AssaultM16 |
| All times are GMT +5.5. The time now is 09:58. |