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.
Asha said:
1 decade ago
What is an round off? How the given program get execute?
Akshatha said:
1 decade ago
@Sasikumar.
You said that 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, but in the explanation part they have given an example in that the o/p of ceil(1.44) is 2 how can it be? it was suppose to b 1 right?
You said that 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, but in the explanation part they have given an example in that the o/p of ceil(1.44) is 2 how can it be? it was suppose to b 1 right?
Dhanshri said:
1 decade ago
Friends there is no any functions like roundup() and roundto() in C language.
Poorni said:
1 decade ago
What is mean by ceil and round to? What is the difference between ceil, roundto and roundup?
Lokesh said:
1 decade ago
Guys ceil() function deletes the fractional value and increments the number by 1, whereas floor() function deletes the fractional part and displays the number. Here in these two functions the fractional part is not considered.
Eg:
ceil(1.66) = 2
ceil(1.10) = 2
floor(1.90)= 1
floor(1.33) = 1
Eg:
ceil(1.66) = 2
ceil(1.10) = 2
floor(1.90)= 1
floor(1.33) = 1
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.
Alina said:
1 decade ago
ceil(1.44) = 1.00 and roundup(1.44) = 1.00 so both are same?
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.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers