Posts

Showing posts from July, 2018

WAP in java to check whether a number is pronic number or not

import java.util.*; class loop { public static void main(String args[]) { Scanner ob=new Scanner(System.in); int a,n=0,k=0; System.out.println("Enter a"); a=ob.nextInt(); for(int i=1;i<=a;i++) { if(a==i*(i+1)) k=1; } if(k==1) System.out.println("Pronic or heteromecic Number"); else System.out.println("not Pronic Number"); } }

WAP in Java to check whether a number is niven number or not

import java.util.*; class Harshad_Number_or_Niven_no { public static void main(String args[]) { Scanner sc=new Scanner(System.in); int a,r,s=0,t; System.out.println("Enter the no."); a=sc.nextInt(); t=a; while(a>0) { r=a%10; s=s+r; a=a/10; } if(t%s==0) System.out.println("niven no."); else System.out.println("not niven no."); } }

WAP to check whether a number is neon number or not

import java.util.*; class loop{ public static void main(String args[]) { int n,r=0,m,d; Scanner ob=new Scanner(System.in); System.out.println("enter the no:"); n=ob.nextInt(); m=(n*n); while(m!=0) { d=m%10; r=r+d; m=m/10; } System.out.println(+r); if(r==n) System.out.println("neon no"); else System.out.println("not neon"); } }

WAP in JAVA to check whether a number is armstrong or not

import java.util.*; class loop{ public static void main(String args[]) { int a,s=0,n; Scanner ob=new Scanner(System.in); System.out.println("enter the no:"); n=ob.nextInt(); while(n!=0) { a=n%10; s=s+(a*a*a); n=n/10; } System.out.println(+s); if(n==s) System.out.println("armstrong no"); else System.out.println("not armstrong"); } }

WAP in JAVA to check whether a number is palindrome or not

import java.util.*; class loop{ public static void main(String args[]) { int n,k,s=0; Scanner ob=new Scanner(System.in); System.out.println("enter the nos:"); n=ob.nextInt(); while(n!=0) { k=n%10; s=((s*10) + k); n=n/10; } if(n==s) System.out.println("palindrome"); else System.out.println("not palindrome"); } } input:enter the nos:101 ouput:palindrome

WAP in Java to Enter the number a print sum of the digit

import java.util.*; class loop{ public static void main(String args[]) { int n,k,sum=0; Scanner ob=new Scanner(System.in); System.out.println("enter the nos:"); n=ob.nextInt(); while(n!=0) { k=n%10; sum=sum+k; n=n/10; } System.out.println("sum="+sum); } } input:enter the nos:123 ouput:sum=6