InterviewSolution
Saved Bookmarks
| 1. |
Write a program to enter a integer number and check whether the number is duck or not.A number is said to be duckif the digit zero is present in the number. example sample input:5063 sample output:it is a duck number.sample input:5459sample output:it is not a duck number... .give the answer by using scanner |
|
Answer» java.util.*;class Duck{public STATIC VOID main(String args[]){SCANNER sc=new Scanner(System.in)System.out.println("ENTER any number");int n=sc.nextInt()boolean found=false;while(n!=0){int d=n%10;if(d==0){System.out.println("Duck number");found=true;BREAK;}}if(found==false){System.out.println("Not a duck number");}}} |
|