Tuesday, 27 August 2013

c program to demonstrate important and unknown functions in "math.h" library

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

/* This program demonstrates most of the functions defined in math.h library of c89  */
int main()
{
    int i=0;
    double c=0;  //used for o/p
    double a=0,b=0; //used as i/p
    long double l=0;

    /*.................................//returns the cube root of the  inpuvalue

    printf("enter  an value to find cuberoot ofit:");
    scanf("%lf",&a);
    c=cbrt(a);
    printf("cube root  = %lf",c);
    .....................................................*/




    /*................................................//demonstrates the copysign function

    printf("enter the value:");
    scanf("%lf",&a);
    printf("enter either positive or negative value:");
    scanf("%lf",&b);
    c=copysign(a,b); //assign the sign of b and magnitude of a to c
    printf("%lf",c);
......................................................................................................*/


/*..................................................//...................................."expm1".....function demonstration

printf("enter an value:");
scanf("%lf",&a);
c=expm1(a);
printf("exp(value)-1=%lf",c);
.............................................................................................*/



/*.........................................//find large or minimum.......fldm

printf("enter two values:");
scanf("%lf ,%lf",&a,&b);
c=fdim(a,b);
 printf("c=%lf",c);
//else        printf("a is greater than b........>>c=%lf",c);
................................................................*/

/*.............>>>>>>>>>>>>//............"fmax".&&"fmin"...........functions
printf("enter the values of a and b:");
scanf("%lf %lf",&a,&b);
//c=fmax(a,b);
c=fmin(a,b);
//printf("\nmaximum of a and b is = %lf",c);
printf("\nminimum of a and b is = %lf",c);
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/


/*.................................................//...."fma function demonstration...............
printf("enter the values of a , b , c:");
scanf("%lf %lf %lf",&a,&b,&c);
c=fma(a,b,c);
printf("\nc=%lf",c);
.....................................................*/



//"fmod"  function
/*.................................................printf("enter the values of a ,b:");
scanf("%lf %lf ",&a,&b);
c=fmod(a,b);
printf("c=%lf",c);
...........................................................*/



/*...........................................................//...........ilogb..............................
printf("enter the value of a ");
scanf("%lf",&a);
c=ilogb(a);
printf("exponential of a=%lf ",c);
.....................................................................*/


//ldexp function
printf("enter the value of a and exponent :");
scanf("%lf %lf",&a,&b);
c=ldexp(a,b);
printf("c=%lf",c);

    getchar();
    return 0;

}

No comments:

Post a Comment