Write a program in java to input a 5 digit
number & print the product of all its
digit.
Answers
Answered by
1
Answer:
Explanation:
import java.util.*;
class Prahul
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
int no,dup,prod=1,ud;
System.out.println("enter a 5");
no=sc.nextInt(); //store the no given by user
dup=no; //stores the duplicate no
while(dup!=0)
{
ud=dup%10; //store the unit digit
prod=prod*ud; // stores product of each digits
dup=dup/10; //removes the last digit
}
System.out.println("product of digits = "+prod);
}
}
Similar questions