how to print odd numbers from 1 to 100 using recursion in c++

#include<iostream>
void rec(int);
void temp(int);
using namespace std;
int main()
{
int a=0;
cout<<"odd numbers 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

programme for armstrong number for 3 digit in java

armstrong number import java.util.Scanner; class Mittu {     public static void main(String []args)     {         Scanner s=new Sca...