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 4 of 8.
Yogesh said:
1 decade ago
Here you are saying that for >. 5 then only the value will round to next highest integer but if we give as ceil (2.1) also we get ans as 3 then how?
Shankar said:
1 decade ago
#include<stdio.h>
int main()
{
int x;
x=ceil(1.2) ;
printf("%f ",x);
printf("%f",ceil(1.2));
return 0;
}
Difference b/w two statement in this program.
1. x=ceil(1.2) ;
2. printf("%f",ceil(1.2));
int main()
{
int x;
x=ceil(1.2) ;
printf("%f ",x);
printf("%f",ceil(1.2));
return 0;
}
Difference b/w two statement in this program.
1. x=ceil(1.2) ;
2. printf("%f",ceil(1.2));
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.
Shalini verma said:
1 decade ago
Give some examples of ceil() and floor() and roundup() and roundto().
Anil Soni said:
1 decade ago
What is roundup() & why we use?
Sneha said:
1 decade ago
What the difference between roundup() and ceil()?
Cutie said:
1 decade ago
What is the difference between ceil & roundup and floor & roundto?
Alina said:
1 decade ago
ceil(1.44) = 1.00 and roundup(1.44) = 1.00 so both are same?
Elumalai said:
1 decade ago
Floor : It is used to eliminate the float(decimal)numbers that means if the value is 3.50 means the result is 3.00. It eliminate the .50.
Ceil : It is used to round the next integer value that means if the value is 3.50 or 3.4 the result is 4.
Round : It is used to round up or round down the float numbers based on the numbers. If the value is <3.5 then the result is 3 and >= 3.5 then v will get 4.
Ceil : It is used to round the next integer value that means if the value is 3.50 or 3.4 the result is 4.
Round : It is used to round up or round down the float numbers based on the numbers. If the value is <3.5 then the result is 3 and >= 3.5 then v will get 4.
Raghu Teja said:
1 decade ago
I understood about ceil and need more clarity about floor().
Can anyone explain me about floor() with an suitable example?
Can anyone explain me about floor() with an suitable example?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers