b374k
v10
today : | at : | safemode : ON
> / home / facebook / twitter / youtube /
name author perms com modified label

Show the ODD number ( recursive ) pramana rwxr-xr-x 0 12:17 am

Filename Show the ODD number ( recursive )
Permission rw-r--r--
Author pramana
Date and Time 12:17 am
Label
Action
Odd number is any number not divisible by 2 ...
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

 

Jayalah Indonesiaku © 2010 Pramana's BLOG
VB (Vio b374k) Template design by p4r46hcyb3rn3t