floor()

#include <stdio.h>
int main() {
printf("Number = %.4f", floor(14.23)); // 14.0000
printf("\nNumber = %.4f", floor(14.831)); // 14.0000
printf("\nNumber = %.4f", floor(-17.831)); // -18.0000
printf("\nNumber = %.4f", floor(-17.23)); // -18.0000
return 0;
}
We will get highest integer less than the input data by using floor() function. Output is the nearest integer ( on lower side ) of the number.
#include <stdio.h>
#include <math.h>

int main(void){
float num; // num is declared as float variable
num=17.873;     // data is stored
printf("num = %.4f", floor(num)); // final output
return 0;
}
The above code will give this output.
num = 17.0000

Example with negative value

#include 
#include 
int main(void){
float num; // num is declared as float variable
num=-17.873;     // data is stored
printf("num = %.4f", floor(num)); // final output
return 0;
}
Output is here
num = -18.0000

Subscribe

* indicates required
Subscribe to plus2net

    plus2net.com



    Post your comments , suggestion , error , requirements etc here




    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2024 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer