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 7 of 8.
Sai prashanthi said:
1 decade ago
Thanks to sasi and jayashri.
L.sirisha said:
1 decade 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:
1 decade 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:
1 decade ago
Confusion!!! But some time both the function is give the same out put confuse!
Sudha said:
1 decade ago
Thanks jayasri.
Deepika said:
1 decade ago
Thanks to sasi.
Jayasri said:
1 decade ago
roundup() function preforms just rounding the value 10.5 to 11
and roundto() function performs like specification if u want to display 2 decimal r three decimal. its like 123.345 u want it for 0 decimal means it displays 123. and for 1 its displays 123.3 like wise it performs
and roundto() function performs like specification if u want to display 2 decimal r three decimal. its like 123.345 u want it for 0 decimal means it displays 123. and for 1 its displays 123.3 like wise it performs
Amit Wadhe said:
1 decade ago
Usage:
#include <math.h>
y = floor( x );
Where:
double x, y;
Description:
"floor" returns the largest integer (represented as a double precision number) that is less than or equal to "x".
#include <math.h>
y = floor( x );
Where:
double x, y;
Description:
"floor" returns the largest integer (represented as a double precision number) that is less than or equal to "x".
Preethi said:
1 decade ago
Give the explaination of functions roundof(),roundto()
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