unique number

  Write a program to input a numbers and check it is unique number or not.

A number is said to be unique if the digits of the numbers doesn’t match each other. 

Example : Number : 2015,12345 .....


 

import java.util.Scanner; class uniquenumber { public static void main() { int x,temp1,temp2,l1=0,flag=0; System.out.println("ENTER A NUMBER"); Scanner in = new Scanner(System.in); x = in.nextInt(); temp1=temp2=x; for (;temp1>0;temp1=temp1/10) { l1=temp1%10; temp2=x; for(;temp2>0;temp2=temp2/10) { if(l1==temp2%10 && temp1!=temp2) flag=1; } } if(flag==0) System.out.println("UNIQUE NUMBER"); else System.out.println("NOT A UNIQUE NUMBER"); } }




For any desired program, please comment below. We will try our best to make that program available.

Comments

Popular Posts