Library Functions

Q1:
What will be the output of the program?
#include<stdio.h>
#include<math.h>

int main()
{
    float i = 2.5;
    printf('%f, %d', floor(i), ceil(i));
    return 0;
}

A 2, 3

B 2.000000, 3

C 2.000000, 0

D 2, 0

ANS:A - 2, 3

Both ceil() and floor() return the integer found as a double. floor(2.5) returns the largest integral value(round down) that is not greater than 2.5. So output is 2.000000. ceil(2.5) returns 3, while converting the double to int it returns '0'.
So, the output is '2.000000, 0'.



img not found
img

For help Students Orientation
Mcqs Questions

One stop destination for examination, preparation, recruitment, and more. Specially designed online test to solve all your preparation worries. Go wherever you want to and practice whenever you want, using the online test platform.