CEILING:
Function Declaration: double ceilf(double);
this function rounds a number up. It returns the smallest integer greater than or equal to x.

Flooring:

Function Declaration:double floor(double x)
this function rounds a number up. returns the largest integer value less than or equal to x.

Required Header: #include <cmath>

/* (c) wikistack.com
Copy or publish or modification is allowed with
same copyright */
#include<iostream>
#include<cmath>
using namespace std;

int main() {
	double n = 2.4;
	double result = 0;
	double result_2 = 0;

	result = ceilf(n);

	cout << "CEILING" << endl;
	cout << "Ininitial number = " << n << endl;
	cout << "Initial number rounded up = " << result << endl;

	result_2 = floor(n);

	cout << "Flooring" << endl;
	cout << "Initial number =" << n << endl;
	cout << "Inintial number rounded up =" << result_2 << endl;

	return 0;
}

 

output:

CEILING
Ininitial number = 2.4
Initial number rounded up = 3
Flooring
Initial number =2.4
Inintial number rounded up =2



Related Contents to follow