trunc() function

The trunc() function rounds the argument towards zero and returns the nearest integral value that is not larger in magnitude than the argument.

Example:

Input:  x = 13.567
Output: 13

Approach

C++

#include <bits/stdc++.h>
using namespace std;

int main()
{
    double x = 13.567;

    cout << trunc(x);

    return 0;
}


No comments:

Post a Comment