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:
80 comments Page 1 of 8.

Pavan Shinde said:   8 years ago
@All.

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

Vini said:   6 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)

Shalini verma said:   1 decade ago
Give some examples of ceil() and floor() and roundup() and roundto().

Ajay said:   1 decade ago
The Explanation which you people were given was very good. But some people are saying one thing i.e., ceil (1.2) gives 1, and some are saying 2, may I please know the correct answer?

I am confused!

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.


Post your comments here:

Your comments will be displayed after verification.