Filename | Show the ODD number ( recursive ) |
Permission | rw-r--r-- |
Author | pramana |
Date and Time | 12:17 am |
Label | Alpro cases |
Action |
This time I will show odd number of 0-20 recursively ....
The following is the source code of this program (c + +)
#include <cstdlib>
#include <iostream>
using namespace std;
class odd{
friend istream& operator>>(istream&, odd&);
friend ostream& operator<<(ostream&, odd&);
public:
odd();
void rekursif();
private:
int i,n;
};
odd::odd(){cout<<endl;
cout<<"\t\Show the ODD number from 0-20 with RECURSIVE"<<endl<<endl;
cout<<endl;
}
ostream& operator<<(ostream& out, odd& keluar){ }
void odd::rekursif(){
n=0;
for(i=20;i>=n;i--){
if(i%2!=0){cout<<i<<" , ";}
else{}
}
cout<<endl<<endl;
}
int main(int argc, char *argv[])
{
odd siap;
siap.rekursif();
cout<<siap;
cout<<endl;
system("PAUSE");
return 0;
}
0 comments:
Post a Comment