java program to pass an integer as argument and check whether all digits in it are unique or not

Programming Example

Write a program to pass an integer as argument, and check whether all digits in it are unique or not.

Solution

class Unique
{
	public static void main(int n)
	{
		int i,s=0,c=0,d,j,d1,f=0;
		for(i=n;i>0;i=i/10)
		{
			d1=i%10;
			for(j=i/10;j>0;j=j/10)
			{
				d=j%10;
				if(d==d1)
					f=1;
			}
		}
		if(f==0)
			System.out.println(“All digits are unique”);
		else
			System.out.println(“All digits are not unique”);
	}
}
Output

CCC Online Test 2021 CCC Practice Test Hindi Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level NIELIT Study material and Quiz Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Website development Company in Allahabad