C Programming - Declarations and Initializations - Discussion

Discussion Forum : Declarations and Initializations - General Questions (Q.No. 5)
5.
How would you round off a value from 1.66 to 2.0?
ceil(1.66)
floor(1.66)
roundup(1.66)
roundto(1.66)
Answer: Option
Explanation:
/* Example for ceil() and floor() functions: */

#include<stdio.h>
#include<math.h>

int main()
{
    printf("\n Result : %f" , ceil(1.44) );
    printf("\n Result : %f" , ceil(1.66) );
 
    printf("\n Result : %f" , floor(1.44) );    
    printf("\n Result : %f" , floor(1.66) );

    return 0;
}
// Output:
// Result : 2.000000
// Result : 2.000000
// Result : 1.000000
// Result : 1.000000
Discussion:
79 comments Page 1 of 8.

Pavan Shinde said:   7 years ago
@All.

ceil()---> Means up.(for ex: 1.66----> 2.000000).
floor()--->Means Down.(for ex:1.44--->1.000000).
(22)

Vini said:   5 years ago
Thanks all for explaining it clearly.
(9)

V. Sai Prathyusha said:   6 years ago
I can't understand this. Please explain once.
(8)

V. Sai Prathyusha said:   6 years ago
Anyone, please write the program using four functions.
(7)

Ruchitha said:   6 years ago
I can't get it, please explain me guys.
(2)

Sonali said:   8 years ago
What is the meaning of roundup and roundto function?
(1)

Anil Soni said:   1 decade ago
What is roundup() & why we use?

Asha said:   1 decade ago
What is an round off? How the given program get execute?

Vikram said:   1 decade ago
It is good but the people who are doing basics to under stand for them can you explain in deep manner.

Lokesh said:   1 decade ago
Guys ceil() function deletes the fractional value and increments the number by 1, whereas floor() function deletes the fractional part and displays the number. Here in these two functions the fractional part is not considered.

Eg:
ceil(1.66) = 2
ceil(1.10) = 2
floor(1.90)= 1
floor(1.33) = 1


Post your comments here:

Your comments will be displayed after verification.