Dcoder icon

Ceil and Floor @ Dcoder

By Lochard | As a newbie programmer | 16 Apr 2023


Problem: In mathematics and computer science, the floor and ceiling functions map a real number to the largest previous and the smallest following integer, respectively. consider a number x.

ceil(x) : Returns the smallest integer that is greater than or equal to x.

floor(x) : Returns the largest integer that is smaller than or equal to x.Given a number print ceil and floor of that number.

Input: Each input consist of 1 real Number.

Output: Print two integer denoting ceil and floor of the given number respectively.

Constraints: 1<=X<=100

Sample Input: 5.67

Sample Output: 

6 5

from math import ceil, floor
x = float(input())
print(ceil(x), floor(x))

How do you rate this article?

6


Lochard
Lochard

20240228 Arrived in the UK for about 2 week. All my fears persist. Some are even getting worse. https://github.com/locharp/asylum_diary/


As a newbie programmer
As a newbie programmer

Sharing entry level codes. My snippets on GitHub https://github.com/locharp/code-snippets

Send a $0.01 microtip in crypto to the author, and earn yourself as you read!

20% to author / 80% to me.
We pay the tips from our rewards pool.