Write a function that computes the average of the digits in an integer and use the following function header.double average Digits(long n)
double averageDigits(long n) {
int foo = 0, ln = 0;
while (n > 0)
{
int dig = n % 10;
foo += dig;
n /= 10;
ln++;
}
return foo/ln;
}
Comments
Leave a comment