- trunc( ) function in C truncates the decimal value from floating point value and returns integer value.
- ”math.h” header file supports trunc( ) function in C language. Syntax for trunc( ) function in C is given below.
double trunc (double a);
float truncf (float a);
long double truncl (long double a);
float truncf (float a);
long double truncl (long double a);
Example program for trunc( ) function in C:
#include <stdio.h> #include <math.h> int main() { printf ("truncated value of 16.99 = %f\n", trunc (16.99) ); printf ("truncated value of 20.1 = %f\n", trunc (20.1) ); return 0; }
Output:
truncated value of 16.99 = 16.000000 truncated value of 20.1 = 20.000000 |
0 comments:
Post a Comment