Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

c++

What is llround() function in C++?

Educative Team

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

llround() is the built-in C++ function. It is used to round off the specified number to the nearest value.

Syntax

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.

Return

It returns long long integer, which comprises of 8 bytes.

Code

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;
}

RELATED TAGS

c++
Copyright ©2022 Educative, Inc. All rights reserved

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring