Site icon Codeforcoding

ceil function in C programming language

ceil function in C programming language

In this tutorial, we will learn about ceil function in C programming language

In the C Programming Language, the ceil()  returns the nearest integer value which is greater than or equal to the value of floating point passed value.

Declaration

Syntax

The syntax of  the ceil() function in the C programming Language

double ceil(double x);

parameters or Argument

x is the parameter or argument of this , x is a floating point value.

Return value

when the value for x is passed, this is returns the ceil value of x

Required Header

In the C Language, the required header file for ceil() function is

#

include <math.h>

ceil function in C

Example

program

The following example explains the usage of ceil() function

//Example for ceil math function in C language
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{       //Define temporary variables
    double a=12.1,b=12.9,c=-12.1,d=-12.9;
     //Calculate and display ceil value for given value
        printf("ceil value of a: %f\n",ceil(a));
        printf("ceil value of b: %f\n",ceil(b));
        printf("ceil value of c: %f\n",ceil(c));
        printf("ceil value of d: %f\n",ceil(d));
    return 0;
}

 

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

ceil value of a: 13.000000

ceil value of a: 13.000000

ceil value of a: -12.000000

ceil value of a: -12.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

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

floor function in C programming language
round function in C programming language
Exit mobile version