CHECKING WHETHER THE NO IS UNIQUE DIGIT OR NOT

 THE SOLUTION

import java.util.*;

class unique_digit

{void main()

    {

        Scanner ob=new Scanner(System.in);

        int n,m,i,c,f=0,d;

        System.out.println("Enter a no");

        n=ob.nextInt();

        m=n;

        for(i=0;i<=9;i++)

        {c=0;

            while(n!=0)

            {

                d=n%10;

                if(d==i)

                {

                    c++;

                }

                n=n/10;

            }

            if(c>1)

            {

                f=1;

                break;

            }

        }

        if(f==0)

        System.out.println("yes");

        else

        System.out.println("no");

    }

}


thanks for asking us

Post a Comment

Please Select Embedded Mode To Show The Comment System.*

Previous Post Next Post

It looks like you're using an ad blocker. We rely on ads to keep our site free, please whitelist us!

Click here to continue

Please whitelist our site to continue enjoying our content.

Whitelist | Close