Search
 
SCRIPT & CODE EXAMPLE
 

CPP

c++ round number down

#include <iostream>
#include <cmath>

using namespace std;

int main()
{
	double num1 = 4.8;
  	double num2 = 4.3;
  	cout << floor(num1) << endl; // --> 4
  	cout << floor(num2) << endl; // --> 4
}
Comment

c++ round number up

#include <iostream>
#include <cmath>

using namespace std;

int main()
{
	double num1 = 4.8;
  	double num2 = 4.3;
  	cout << ceil(num1) << endl; // --> 5
  	cout << ceil(num2) << endl; // --> 5
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: c++ int to qstring 
Cpp :: c++ print colorful 
Cpp :: check gpu usage jetson nano 
Cpp :: how to print a decimal number upto 6 places of decimal in c++ 
Cpp :: maximum in vector 
Cpp :: simple C++ game code 
Cpp :: programs for printing pyramid patterns in c++ 
Cpp :: output coloured text in cpp 
Cpp :: check if key exists in map c++ 
Cpp :: round all columns in R dataframe to 3 digits 
Cpp :: merge images opencv c++ 
Cpp :: angle to vector2 
Cpp :: Tech mahindra coding questions 
Cpp :: convert set to vector c++ 
Cpp :: c++ converting centimeters to meters 
Cpp :: what are various sections of process 
Cpp :: c++ double to string 
Cpp :: qt messagebox 
Cpp :: extern shared memory 
Cpp :: 2d vector initialization in cpp 
Cpp :: remove value from vector c++ 
Cpp :: c++ std::copy to cout 
Cpp :: cpp float to int 
Cpp :: convert string to char c++ 
Cpp :: cannot open include file: 
Cpp :: cpp split string by space 
Cpp :: c++ code for selection sort 
Cpp :: C++ Program to Reverse an Integer 
Cpp :: print linked list reverse order in c++ 
Cpp :: how to use decrement operator in c++ 
ADD CONTENT
Topic
Content
Source link
Name
2+8 =