// how to print evan numbers from 1 to 100 using recursion in c++
#include<iostream>
#include<conio.h>
void rec(int);
void temp(int);
using namespace std;
int main()
{
int a=0;
cout<<"evan number from 1 to 40\n";
temp(a);
}
void rec(int a)
{
a++;
if(a%2==0)
cout<<a<<endl;
if(a==100)
{
exit(0);
}
temp(a);
}
void temp(int a)
{
rec(a);
}
#include<iostream>
#include<conio.h>
void rec(int);
void temp(int);
using namespace std;
int main()
{
int a=0;
cout<<"evan number from 1 to 40\n";
temp(a);
}
void rec(int a)
{
a++;
if(a%2==0)
cout<<a<<endl;
if(a==100)
{
exit(0);
}
temp(a);
}
void temp(int a)
{
rec(a);
}
No comments:
Post a Comment