Quote Originally Posted by brewgrass View Post
I am new to programming and chose C++ as a starting language. I am creating a program (for practice). I want the user to enter 5 numbers that are a combination of integers and decimals. How would I round decimals < .50 down to the nearest integer and decimals that are >= .50 to round up. I do not want to truncate because that will always round down.
You probably want to do this:

Code:
double entered;
cin >> entered;
double rounded = (double)(long)(entered + 0.5);
This may not work for very large numbers (like more than several billions), which cannot be represented by the 'long' integer.