ADVERTISEMENT
ADVERTISEMENT

C program to demonstrate example of floor() and ceil() functions

This program will demonstrate the example of floor() an ceil() function in c programming language. Both functions are library functions and declare in math.h header file.

Example of floor() and ceil() functions in c

/* C program to demonstrate example of floor and ceil functions.*/
 
#include <stdio.h>
#include <math.h>
 
int main()
{
    float val;
    float fVal,cVal;
 
    printf("Enter a float value: ");
    scanf("%f",&val);
 
    fVal=floor(val);
    cVal =ceil(val);
    printf("floor value:%f \nceil value:%f\n",fVal,cVal);
    return 0;
}

Output

    Enter a float value: 123.45
    floor value:123.000000 
    ceil value:124.000000

C Basic Programs »



ADVERTISEMENT



ADVERTISEMENT



Comments and Discussions


ADVERTISEMENT

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.