Use ceil(), floor, sqrt, cos - C Function

C examples for Function:Math Function

Description

Use ceil(), floor, sqrt, cos

Demo Code

#include <stdio.h>
#include <math.h>

int main( void )
{

    double x;/*from   w w w .j av a  2  s.co m*/

    printf("Enter a number: ");
    scanf( "%lf", &x);

    printf("\n\nOriginal value: %lf", x);

    printf("\nCeil: %lf", ceil(x));
    printf("\nFloor: %lf", floor(x));
    if( x >= 0 )
        printf("\nSquare root: %lf", sqrt(x) );
    else
       printf("\nNegative number" );

    printf("\nCosine: %lf\n", cos(x));
    return 0;
}

Related Tutorials