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
Karmehavannan

I am Mr S.Karmehavannan. Founder and CEO of this website. This website specially designed for the programming learners and very especially programming beginners, this website will gradually lead the learners to develop their programming skill.

Recent Posts

C# inverted full pyramid star pattern

C# inverted full pyramid star pattern In this article, we will discuss the concept of…

3 weeks ago

C# Full Pyramid star pattern program

C# Full Pyramid star pattern program In this article, we will discuss the concept of…

1 month ago

Program to count vowels,consonants,words, characters and space in Java

Program to count vowels, consonants, words, characters and space in Java In this article, we…

1 month ago

How to print multiplication table using Array in C++ language

How to print multiplication table using Array in C++ language In this post, we will…

1 month ago

C Program to multiplication table using Array

C Program to multiplication table using Array In this tutorial , we will discuss about…

2 months ago

Java program to check odd or even using recursion

Java program to check odd or even using recursion In this tutorial, we discuss a…

2 months ago