Code:
import java.util.*;
class reverse
{
public static void main(String []args)
{
int a,b,c,reverse=0;
Scanner in=new Scanner (System.in);
System.out.print("enter any integer number: ");
a=in.nextInt();
int sum=0;
int n=a;
while (n!=0)
{
int lastdigit=n%10;
sum +=lastdigit;
n /=10;
}
System.out.println("sum of the digits is "+sum);
while(sum!=0)
{
reverse=reverse*10;
reverse=reverse+(sum%10);
sum=sum/10;
}
System.out.println("Reverse of the sum is "+reverse);
}
}
No comments:
Post a Comment