A number is said to be Duck if the digit zero is (0) present in it. The program displays the message accordingly .
Input : 5063 Output: Duck number.
Input : 7453 Output: Not a Duck Number .
import java.util.*;
class Duck_number
{
public static void main(String args[])
{
Scanner sc= new Scanner(System.in);
int n,r,p,c=0;
System.out.println("Enter the no ");
n=sc.nextInt();
while(n>0)
{
r=n%10;
if(r==0)
c++;
else
p=r;
n=n/10;
}
if(c>0)
System.out.println("Duck number");
else
System.out.println("Not Duck number");
}
}
Input : 5063 Output: Duck number.
Input : 7453 Output: Not a Duck Number .
import java.util.*;
class Duck_number
{
public static void main(String args[])
{
Scanner sc= new Scanner(System.in);
int n,r,p,c=0;
System.out.println("Enter the no ");
n=sc.nextInt();
while(n>0)
{
r=n%10;
if(r==0)
c++;
else
p=r;
n=n/10;
}
if(c>0)
System.out.println("Duck number");
else
System.out.println("Not Duck number");
}
}