Write a function called truncate It is passed 2 parameters a
Write a function called truncate. It is passed 2 parameters, a float f and an integer d. The function truncates f so that it has d digits to the right of the decimal point. For example:
You may assume that the second parameter d will be a positive integer.
Solution
Below is the Funtion about the same
double truncate(double d, int n)
{
double k=Math.pow(10,n); System.out.println(k);
int aux = (int)(d*k);
double result = aux/k;
return result;
}
