Loop_Practise_Que_08

Home / Java Practice Question / Loop_Practise_Que_08

Loop_Practise_Que_08


WAP to calculate the sum of digits in an given Number ...

Program : 


public class Loop{
public static int countDigit(int num){
int sum=0;
for(int i=num;i>0;i=i/10){
int digit=i%10;

sum+=digit;
}

return count;
}
}