Q:

Write C# program to calculate product of digits of a number

0

Write C# program to calculate product of digits of a number

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

I have used Visual Studio 2012 for debugging purpose. But you can use any version of visul studio as per your availability..

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
public class csharpExercise
{
    static void Main(string[] args)
    {
 
        int num, rev = 0;
 
        // Reading number
        Console.Write("Enter any number: ");
        num = Convert.ToInt32(Console.ReadLine());
 
        //finding reverse number using while loop
        while (num > 0)
        {
            rev = rev * 10;
            rev = rev + num % 10;
            num = num / 10;
        }
 
        Console.Write("Reversed number is = "+ rev);
 
        Console.ReadLine();
    }
}

Result:

Enter any number: 123456

Reversed number is = 654321

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Write C# program to calculate power using while & ... >>
<< Write C# program to find first and last digit of a...