TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Aditya Varma Mudunuri
NA
58
104.2k
product of digits in a number
Jun 6 2014 1:05 PM
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 ");
num = double.Parse(Console.ReadLine());
/* 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));
}
}
}
Reply
Answers (
1
)
How to update usercontrol from javascript in asp.net?
Link image with session