programe to add all the digit of a number (using java)

 

// ex-125  ans-1+2+5=8

class add_digit

{

public static void main(String args[])

{

int  no=125, sum=0,b=0;

while(no>0)

{

b=n0%10;

no=no/10;

sum=sum+b;

}

System.out.println(sum);

}

}

Comments

Popular posts from this blog