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?
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.
Nikita said:
1 decade ago
What is the difference b/w ceil & floor, and also explain the work of roundup and roundto ?
Sayed Nasir said:
1 decade ago
What is the use of ceil() and floor() function?
S.Sasikumar said:
1 decade ago
ceil()-This function works as follows: if the value is greater than or equal to (_.5) then, it round off a value into the next integer value. Otherwise it round off into before integer value of the given float number. Floor()-This function works as follows: if the value is floating point number then it eliminates the float values and gives only integer value before the given float number.
Bhavya said:
1 decade ago
ceil(d):double, return a value rounded up to the next higher integer.
floor(d):double,return a value rounded down to the next lower integer.
floor(d):double,return a value rounded down to the next lower integer.
Vineettyagi said:
1 decade ago
ceil()-This function works as follows: if the value is greater than or equal to (_.5) then, it round off a value into the next integer value
Yazhini said:
1 decade ago
Good explanation.
Sindhu said:
1 decade ago
What is difference between roundup() and roundto() ?
Sindhu said:
1 decade ago
What is use of roundup and roundto?
Jhishu said:
1 decade ago
Thanks to S. Sasikumar.
Teju said:
1 decade ago
What is difference between roundup() and roundto().
Are they math fn's or not?
Are they math fn's or not?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers