# Answer to Question #27374 in C++ for red rose

Question #27374

A function is defined by the following code:

double Fraction To Decimal(double numerator, double denominator)

{

return (numerator/denominator);

}

Complete the Fraction To Decimal()function so that it correctly calculates and

returns the decimal value of values passed to it when it’s called

double Fraction To Decimal(double numerator, double denominator)

{

return (numerator/denominator);

}

Complete the Fraction To Decimal()function so that it correctly calculates and

returns the decimal value of values passed to it when it’s called

Expert's answer

Actually this is very close to the right implementation ofthis function:

double FractionToDecimal (double numerator, doubledenominator) {

returnnumerator / denominator;

}

PS. to output you can choose how many characters are tohold with the decimal part.

Example:

#include <stdio.h> //for printf

...

printf ("%.2f

" , 1.02345);

...

//output will be 1.02

//Because the last two characters are to hold the decimalpart.

double FractionToDecimal (double numerator, doubledenominator) {

returnnumerator / denominator;

}

PS. to output you can choose how many characters are tohold with the decimal part.

Example:

#include <stdio.h> //for printf

...

printf ("%.2f

" , 1.02345);

...

//output will be 1.02

//Because the last two characters are to hold the decimalpart.

Need a fast expert's response?

Submit orderand get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

## Comments

## Leave a comment