Question 1
Back to Exercise
What is the output of the following C program?
#include <math.h>
#include <stdio.h>
int main(void) {
printf("%.0f %.0f %.1f\n", pow(3, 4), sqrt(169), fabs(-0.5));
printf("%.1f %.1f\n", ceil(-2.5), floor(-2.5));
return 0;
}
- A 81 13 0.5 -2.0 -3.0 Correct
- B 81 13 0.5 -3.0 -2.0
- C 12 13 0.5 -2.0 -3.0
- D 81 13 -0.5 -2.0 -3.0
Correct Answer: Option A
ceil rounds toward +∞ (−2.0) and floor toward −∞ (−3.0), also for negative numbers.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!