Program to check for Duck Number


Write a Program in Java to input a number and check whether it is a Duck Number or not.

Note: A Duck number is a number which has zeroes present in it, but there should be no zero present in the beginning of the number. For example 3210, 7056, 8430709 are all duck numbers whereas 08237, 04309 are not.



Enter any number : 4013
It is a duck number

Enter any number : 0134
It is not a duck number

Enter any number : 67300987
It is a duck number

[Note: Don't forget to share these resources and links from our website in your social networking sites with your friends and followers.]

A teacher whose aim is to make Java a fun to learn experience for the school students by striving to build clear fundamentals of every concepts and helping students to develop their ability to reason and logically analyze any given programs.

  • sir/madam, can we make this program like this
    public class vv
    public static void main(String args[])

    String n=”562045″; //inputting the number and storing it in a String
    int l=n.length(); //finding the length (number of digit) of the number
    int c=0; //variable for counting number of zero digits
    char ch;
    for(int i=2;i0)
    System.out.println(“It is a duck number”);
    System.out.println(“It is not a duck number”);

Your Turn To Talk

Your email address will not be published.