Untitled
unknown
plain_text
5 months ago
570 B
4
Indexable
import java.util.Scanner; /** * * @author PC */ public class sumandreverse { public static void main(String[] args) { int n, i, j, rev = 0, sum = 0, num; Scanner s = new Scanner(System.in); System.out.println("enter the number:"); num = s.nextInt(); n = num; while (n > 0) { i = n % 10; sum = sum + i; rev = (rev*10) + i ; n=n/10; } System.out.println(sum); System.out.println(rev); } }
Editor is loading...
Leave a Comment