Take two positive integers a and b as input from user. Write a recursive program to print all the even numbers in range [a, b].
Sample input:
1 8
Sample output:
1 8 2 4 6 8
Sample input :
2 11
Sample output::
2 4 6 8 10
#include <iostream>
using namespace std;
int main()
{
    int a,b;
    cout<<"Enter two positive integers: ";
    cin>>a>>b;
    if(a>0 && b>0)
    {
        cout<<"Print all the even numbers in range [a, b]"<<endl;
        for(int i=a;i<=b; i++)
        {
            if(i%2==0)
            {
             cout<<i<<endl;
            }
        }
    }
    return 0;
}
Comments