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:
80 comments Page 2 of 8.
Nikita said:
2 decades ago
What is the difference b/w ceil & floor, and also explain the work of roundup and roundto ?
(1)
S.Sasikumar said:
2 decades 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.
(1)
Bhavya said:
2 decades 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.
(1)
Vineettyagi said:
2 decades 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
(1)
Yazhini said:
2 decades ago
Good explanation.
(1)
Kuldeep said:
1 decade ago
@Maya.
The answer will be 2 because ceil() function only display the next higher integer for the given no.
The answer will be 2 because ceil() function only display the next higher integer for the given no.
Rambabu said:
1 decade ago
Friends ceil(1.00000001)==>2.0 and floor(1.99999999)==>1.0
And there are no functions like roundup and roundto.
I think it help's to you.
And there are no functions like roundup and roundto.
I think it help's to you.
Raj said:
1 decade ago
@Maya the answer will be 2!
Maya said:
1 decade ago
What is the answer if ceil (1.2)?
Does it gives 1 or 2? Please help me I was confused by various explanations over here.
Does it gives 1 or 2? Please help me I was confused by various explanations over here.
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!
I am confused!
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers