import java.util.*;
import java.util.Scanner.*;
public class Main {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int rem = 0;
int rev = 0;
int sum = 0;
if(n>=0)
{
while(n>0)
{
rem = n%10;
sum= sum+ rem;
rev= rev*10 + rem;
n = n/10;
}
System.out.println("Number in reverse = "+ rev);
System.out.println("Sum of Numbers = " + sum);
}
else if(n<0)
{
while(n<0)
{
rem = n%10;
sum= sum+ rem;
rev= rev*10 + rem;
n = n/10;
}
System.out.println("Number in reverse = "+ rev);
System.out.println("Sum of Numbers = " + sum);
}
}
}
I have checked for both negative as well as positive number