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, 8050896, 70709 are all duck numbers whereas 02364, 03401 are not.
The task is to check whether the given number is a duck number or not.
Input : 707069 Output : It is a duck number. Explanation: 707069 does not contains zeros at the beginning. Input : 02364 Output : It is not a duck number. Explanation: in 02364 there is a zero at the beginning of the number.
// C++ Program to check whether
// a number is Duck Number or not.
// Function to check whether
// given number is duck number or not.
// Length of the number(number of digits)
count_zero = 0 ;
i = 1;i < len ;i++)
// Checking for a digit whether it is a '0' or not
// Driver Method
// Extracting the first digit
first_digit1 = num1;
( check_duck(num1) > 0 && first_digit1 !=
"It is a duck number\n"
"It is not a duck number\n"
It is a duck number.
Disclaimer: This does not belong to TechCodeBit, its an article taken from the below
source and credits.
source and credits: http://www.geeksforgeeks.org/check-whether-number-duck-number-not/
We have built the accelerating growth-oriented website for budding engineers and aspiring job holders of technology companies such as Google, Facebook, and Amazon
If you would like to study our free courses you can join us at
http://www.techcodebit.com. #techcodebit #google #microsoft #facebook #interview portal #jobplacements