Multiply Of Digit Program in Java

Multiply Of Digit Program in Java
Multiply Of Digit Program in Java

If a number=1234, then 1*2*3*4 ,Multiply of digit=24


import java.util.Scanner;

public class MultiplyOfDigit
{
    public static void main(String[] args)
    {
        // TODO code application logic here
        int r, n, num,
        mul = 1;
        Scanner sc = new Scanner(System.in);
        System.out.print("Enter number=");
        n = sc.nextInt();
        num = n;
        while (num > 0)
        {
            r = num % 10;
            mul = mul * r;
            num = num / 10;
        }
        System.out.println("Multiply of digit=" + mul);
    }
}

Output:

Enter number=1234
Multiply of digit=24
b. tech. bca icse java java tutorials learn java mca programs

Frequently Asked Questions

If a number=1234, then 1*2*3*4 ,Multiply of digit=24
If a number=1234, then 1*2*3*4 ,Multiply of digit=24