class sumofdigits
{
public static void main(String args[])
{
int n=222;
int sum=0,rem;
while(n!=0)
{
rem=n%10;
sum=sum+rem;
n=n/10;
}
System.out.println("\nsum of digits :"+sum);
System.out.println("\n");
}
}
{
public static void main(String args[])
{
int n=222;
int sum=0,rem;
while(n!=0)
{
rem=n%10;
sum=sum+rem;
n=n/10;
}
System.out.println("\nsum of digits :"+sum);
System.out.println("\n");
}
}