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 6 of 8.
Binit said:
1 decade ago
ceil() - roundup a float no to its upper integer value
ex : ceil(1.9) = 2.0000
ceil(1.1) = 2.0000
floor() - roundup a float no to its lower integer value
ex : floor(1.9) = 1.0000
floor(1.1) = 1.0000
ex : ceil(1.9) = 2.0000
ceil(1.1) = 2.0000
floor() - roundup a float no to its lower integer value
ex : floor(1.9) = 1.0000
floor(1.1) = 1.0000
Suresh said:
1 decade ago
Dear friends, there is no functions like roundup() and roundto().
Suresh said:
1 decade ago
There is a function as round() which gives the rusult as 4 if round(x), x ranges from 3.5 to 3.99 and it is 3 if x ranges from 3.01 to 3.49
Krishna said:
1 decade ago
Thanks for eplanation.
What is static and global variable?
What is static and global variable?
Manojit said:
1 decade ago
If I have this number, 15.4632,
If Round Up to 2 decimal, I get 15.47.
If Round to Nearest 2 decimal, I get 15.46.
If Round Up to 2 decimal, I get 15.47.
If Round to Nearest 2 decimal, I get 15.46.
Sai prashanthi said:
2 decades ago
Thanks to sasi and jayashri.
L.sirisha said:
2 decades ago
What is the difference between roundup() and ceil()?
As both are doing the same thing. ex:ceil(10.5) rounds to a next integer value.i.e.11.even roundup() do the same thing.then what is the difference between these two?
As both are doing the same thing. ex:ceil(10.5) rounds to a next integer value.i.e.11.even roundup() do the same thing.then what is the difference between these two?
Rakesh said:
2 decades ago
#include<stdio.h>
#include<math.h>
void main()
{
printf("%f\n",ceil(1.69));
printf("%f",floor(1.69));
}
#include<math.h>
void main()
{
printf("%f\n",ceil(1.69));
printf("%f",floor(1.69));
}
Parmar Vishal said:
2 decades ago
Confusion!!! But some time both the function is give the same out put confuse!
Sudha said:
2 decades ago
Thanks jayasri.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers