How to create a program using user-defined function that converts a number with decimal points that you will input to a whole number without using the function round()
#include <iostream>
#include <cmath>
usingnamespace std;
float roundoff (float decimals)
{
int result = (int)(decimals + 0.5f);
return result;
}
int main ()
{
float decimal;
cout << "Input a number with decimal point: ";
cin >> decimal;
float result = roundoff (decimal);
cout << "Rounding it off to whole number: " << result << "\n";
return 0;
}