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 8 of 8.

Raj said:   1 decade ago
@Maya the answer will be 2!

Shivaprabhu said:   1 decade ago
Good explanation by binit.

Sravya said:   1 decade ago
Good explanation by binit.

Jhishu said:   1 decade ago
Thanks to S. Sasikumar.

Ranjith said:   8 years ago
Yes, correct @Akshatha.

Yazhini said:   1 decade ago
Good explanation.

Sudha said:   1 decade ago
Thanks jayasri.

Deepika said:   1 decade ago
Thanks to sasi.

Deepa said:   1 decade ago
Thanks.


Post your comments here:

Your comments will be displayed after verification.