60. JAVA Program To find Number of Digits in a Given Number.
How does this program work?
- This program is used to find the sum and product of individual digits of a given number using PHP.
- We can followed by the below code we can get the Output easily.
Here is the code
//Sum and Product.
import java.util.Scanner;public class sum
{
public static void main(String args[])
{
int remainder, temp, sum=0, product=1,n;
System.out.println("Digits Sum and Product");
System.out.println("Enter number:");
Scanner obj = new Scanner(System.in);
n=obj.nextInt();
temp = n;
while (temp!=0)
{
remainder = temp % 10;
sum = sum + remainder;
product = product * remainder;
temp = temp / 10;
}
System.out.println("Sum of digits of Number '"+n+"': "+sum);
System.out.println("Product of digits of Number '"+n+"': "+product);
}
}