79) Write a program to input a number and
check whether it is Adam Number or
not? (122 =144 , 212 =
441 = 144, 144=144 )
import java.util.*;public class Adam_num{public static void main(String args[ ]){Scanner sc = new Scanner (System.in);System.out.println("Enter a number");int a = sc.nextInt();int p = a*a;int r = 0;while(a>0){int d = a%10;r=(r*10)+d;a=a/10;}int p1 = r*r;r=0;while(p1>0){int d = p1%10;r=(r*10)+d;p1=p1/10;}if(p==r){System.out.println("Entered number is a ADAM Number");}else{System.out.println("Entered number is not a ADAM Number");}}}
No comments:
Post a Comment
if you have any doubts, Please let me know.
Your Truly
Shashank Porwal