Site icon Codeforcoding

floor function in C programming language

floor function in C programming language

We will learn about floor function in C programming language

In the C programming Language, the floor() function returns the nearest integer value which is less than or equal to the value for floating point argument to this function

Declaration

Syntax

The syntax of  the floor()  in the C programming Language

double floor(double x);

parameters or Argument

x is the parameter or argument of this function( x is a floating point value).

Return value

when a value for x is passed, this is returns the floor value of x,  largest integer value which is less than or equal to the passed value

Required Header

In the C programming Language, the required header file for floor()  is

#include <math.h>

floor function in C

Example

The following example explains the usage of floor() function

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{   //define the variable
    double a=12.1,b=12.9,c=-12.1,d=-12.9;
//calculate and display the floor value
        printf("floor value of a: %f\n",floor(a));
        printf("floor value of b: %f\n",floor(b));
        printf("floor value of c: %f\n",floor(c));
        printf("floor value of d: %f\n",floor(d));
    return 0;
}

 

When above program is compiled and run ,it will produce the  following result

floor value of a: 12.000000

floor value of a: 12.000000

floor value of a: -13.000000

floor value of a: -13.000000

 

Similar Functions

Other C programming language functions that are  similar to the cosine function      

cosh function   in C  language                               

sinh function in C language

tanh function in C language

abs function in C language

floor function in C language

ceil function in C language

round function in C language

sqrt function in C language

pow function in C language

exp function in C language

log function in C language

log10 function in C language

trunc function in C language

 

 

suggested for you

Function in C language

User defined function in C language

Arithmetic functions in C Language

String function in C language

labs Arithmetic function in C programming language
ceil function in C programming language
Exit mobile version