PROGRAM:
package reverse;
import java.io.*;
public class reverse {
public static void main(String[] args)throws IOException {
BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter a number ");
int num=Integer.parseInt(in.readLine());
int n=num;
int temp=0,rem=0,sum=0;
while(num>0)
{
temp=num%10;
rem=rem*10+temp;
num=num/10;
sum=sum+temp;
}
System.out.println(rem+" is a reverse of "+n);
System.out.println(sum+" is the sum of digit "+n);
// TODO code application logic here
}
}
OUTPUT:
Enter a number
5432
2345 is a reverse of 5432
14 is the sum of digit 5432

0 comments:
Post a Comment
If You Are Asking Some Question On This Comment Then Click On Subscribe by email Link