C++ program to "Count Zeroes in an Integer" using Recursion

This program will show you How to count number of zeroes in a given integer using Recursion.

Example:    Input:10208
                    Output: 2



#include <iostream>

using namespace std;
int ZeroCount(int N,int count)
{
    if(N>=10)
    {
    if(N%10==0)
    {
       count= ZeroCount(N/10,count+1);
    }else
       {
        count=ZeroCount(N/10,count);
       return count;
       }
    }
    return count;
}

int main()
{
    int N;
    cin>>N;
    int y=ZeroCount(N,0);
    cout<<y;
    return 0;
}

Comments

Popular posts from this blog