Pls solve this java program along with variable description for me.
Answers
Answer:
int n=Sc.nextInt();
int n1=n,f=0;
while(n!=0)
{
d=n%10;
while (n1!=n)
{
d1=n1%10;
if(d=d1)
c++;
n1/=10;
}
if(c>1)
{
f=1;
break;
}
n/=10
}
if (f!=1)
System.out.println("Unique");
else
System.out.println("Not Unique");
Question:-
Write a program to accept a number and check whether it is unique or not.
A number is said to be a unique number if it's digit are not repeated.
This is the program.
import java.util.*;
public class Unique_number
{
public static void main(String args[])
{
int n;int flag=1;
Scanner in=new Scanner(System.in);
System.out.println("Enter a number: ");
n=in.nextInt();
int c;
int no=n, x=n;
while(n!=0)
{
int d=n%10;
no=x;
while(no!=0)
{
int r=no%10;
if(r==d)
c++;
no/=10;
}
}
if(c==1)
System.out.println("It is a Unique number");
else
System.out.println("It is not a Unique number");
}
}