Q:

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

0

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.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C programming Basic Input, Output, if else, Ternary Operator based Programs

Similar questions


need a help?


find thousands of online teachers now
Write a C program to Read Formatted Time Once thro... >>
<< Write a C program to demonstrate example of global...