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 5 of 8.
Shalini verma said:
1 decade ago
Give some examples of ceil() and floor() and roundup() and roundto().
Stanly said:
9 years ago
@Raj.
You should use to print the float value by %f instead of %d.
You should use to print the float value by %f instead of %d.
Abdulrahman said:
9 years ago
There is not standard function for rounding in c called roundup().
Suresh said:
1 decade ago
Dear friends, there is no functions like roundup() and roundto().
Alina said:
1 decade ago
ceil(1.44) = 1.00 and roundup(1.44) = 1.00 so both are same?
Krishna said:
1 decade ago
Thanks for eplanation.
What is static and global variable?
What is static and global variable?
Sri said:
1 decade ago
Roundoff means? here why we chose the ceil function only?
Asha said:
1 decade ago
What is an round off? How the given program get execute?
Preethi said:
1 decade ago
Give the explaination of functions roundof(),roundto()
Sirisha said:
9 years ago
What is the difference between roundup() & ceil()?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers