Write a recursive function named printdigitsdivisibleby2 that takes one parameter
which is a long integer number. The function should print the digits in the number that are
divisible by 2.
The prototype of the function is:
void printdigitsdivisibleby2(long);
Example1: Given the number 526, the function prints 2 6
Example2: Given the number 132586, the function prints 2 8 6
Example3: Given the number 14, the function prints 4
انا حليته لاكن مايشتغل

:
هذا الحل
#include <iostream>
using namespace std;
void prlongdigitsdivisibleby2(long);
long main()
{
long num;
cout<<"Enter the number: ";
cin>>num;
prlongdigitsdivisibleby2(num);
return 0;
}
void prlongdigitsdivisibleby2(long num)
{
if (num%2 !=0)
return;
else
{
if (num%2==0)
cout<<num;
prlongdigitsdivisibleby2 (num);
}
}