Java Program To Find Sum And Product Of Digit Example
Chapter:
Interview Programs
Last Updated:
14-06-2016 15:40:59 UTC
Program:
/* ............... START ............... */
public class JavaSumAndProductOfDigit {
public static void main(String args[]) {
int num = 222;
int temp = num,result=0;
//Logic for sum of digit
while(temp>0){
result = result + temp;
temp--;
}
System.out.println("Sum of Digit for "+num+" is : "+result);
//Logic for product of digit
temp = num;
result = 1;
while(temp > 0){
result = result * temp;
temp--;
}
System.out.println("Product of Digit for "+num+" is : "+result);
}
}
/* ............... END ............... */
Tags
Find Sum And Product Of Digit, Java, Interview Programs