llround()
is the built-in C++ function. It is used to round off the specified number to the nearest value.
long long int llround(datatype number)
Here datatypes can be:
double
float
long double
You have to include
math.h
in order to use this function.
It returns long long integer, which comprises of 8 bytes.
double
#include <iostream>#include<math.h>using namespace std;int main() {double number = 380.555;cout <<"The number is :" << number << endl;cout << "The llround() is :"<< llround(number) << endl;return 0;}
float
#include <iostream>#include<math.h>using namespace std;int main() {float number = 10.5;cout <<"The number is :" << number << endl;cout << "The llround() is :"<< llround(number) << endl;return 0;}
long double
#include <iostream>#include<math.h>using namespace std;int main() {long double number = 340.333333;cout <<"The number is :" << number << endl;cout << "The llround() is :"<< llround(number) << endl;return 0;}