Monday, February 28, 2011

0

C Program Language (Math.h Function - Fabs,Floor,Ceil)

  • Monday, February 28, 2011
  • RJ
  • Share
  • These program is all about the functions fabs, floor and ceil. Discover how those function works and the importance in the C programming language. At this time also I will be using math.h which is very important in solving mathematical operations.
    The problem: Show the value of x after each of the following statement is performed.


    a. x =  fabs (7.5)
    b. x = floor  (7.5)
    c. x = fabs (0.0)
    d. x = ceil  (0.0)
    e. x = fabs (-6.4)
    f. x = ceil (-6.4)
    g. x = ceil (-fabs ( -8 + floor (-5.5))) 


    Observe the output below.


    The complete codes for the output.


    #include<stdio.h>
    #include<conio.h>
    #include<math.h>
    #include<stdlib.h>
    main()
    {
    float x;
    printf("a) The Value of X is %.2f\n",-fabs(-7.5));
    printf("b) The Value of X is %.2f\n",floor(7.5));
    printf("c) The Value of X is %.2f\n",fabs(0.0));
    printf("d) The Value of X is %.2f\n",ceil(0.0));
    printf("e) The Value of X is %.2f\n",fabs(-6.4));
    printf("f) The Value of X is %.2f\n",ceil(-6.4));
    printf("g) The Value of X is %.2f\n",ceil(-fabs(-8)+(floor(-5.5))));
    getch();
    }
    

    0 Responses to “C Program Language (Math.h Function - Fabs,Floor,Ceil)”

    Post a Comment

    Subscribe