Advertisement
Tahamina_Taha

Math log, log10, sin, round, trunc, ceil, floor functions

Aug 17th, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.30 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<math.h>
  3. #include<conio.h>
  4. //Math  log, log10, sin, round, trunc, ceil, floor  functions
  5. int main()
  6. {
  7.    double x,y,result;
  8.    printf("Enter the value of x: \n");
  9.    scanf("%lf",&x);
  10.    printf("Enter the value of Y: \n");
  11.    scanf("%lf",&y);
  12.  
  13.  
  14.    result=log(x);//log function  computes the natural logarithm of an argument
  15.    printf("log (%.0lf)=%.1lf\n",x,result);
  16.  
  17.     result=log10(x);//log10 function   computes the base 10 logarithm of an argument.
  18.    printf("log10(%.0lf)=%.1lf\n",x,result);
  19.  
  20.     result=sin(x);//sin function returns the sine of a number.
  21.    printf("sin(%.0lf)=%.1lf\n",x,result);
  22.  
  23.  
  24.     result=round(y);/*round function  returns the nearest integer value of the
  25.      float/double/long double argument passed to this function */
  26.    printf("round of %lf=%.1lf\n",y,result);
  27.  
  28.    result=trunc(y);/*trunc functions  are used to remove digits after
  29.     decimal point and return the modified decimal number. */
  30.    printf("trunc of %lf=%.1lf\n",y,result);
  31.  
  32.    result=ceil(y);//ceil function computes the nearest integer greater than the argument passed.
  33.    printf("ceil of %lf=%.1lf \n",y,result);
  34.  
  35.    result=floor(y);//floor  calculates the nearest integer less than the argument passed.
  36.    printf("floor of %lf=%.1lf\n",y,result);
  37.  
  38.  
  39.     return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement