# QuestionProduct of digits in a Number

##### New member

I want to print the the product of digits in a number using the following code. Plz view the following code and find me the error in it and help me to solve it in 2 different ways using static method and also in general manner using do while loop in the main method

namespace Prime2
{
class ProdOfDigits
{
public static double evalulate(double no)
{
if (no == 0) return 0;
double temp = 1;

do
{
temp = (no % 10) * temp;
no = no / 10;
} while (no > 0);

return temp;
}

static void Main(string[] args)
{
double num,rem,temp=1;

Console.WriteLine("Enter the Number to find the Product of Digits ");

/* do
{
// rem = num % 10;
//temp = rem * temp;
temp = (num % 10) * temp;
num = num / 10;
} while (num>0);*/

/*if (rem==0)
Console.WriteLine("Product of Digits in Number is Zero");*/

Console.WriteLine("Product of Digits in Number is {0}", ProdOfDigits.evalulate(num));
}
}
}

So, you want us to do your homework for you?

Replies
5
Views
1K
Replies
6
Views
474
Replies
1
Views
521
Replies
10
Views
4K
Replies
8
Views
1K