Filename | Show the even number ( recursive ) |
Permission | rw-r--r-- |
Author | pramana |
Date and Time | 9:31 pm |
Label | Alpro cases |
Action |
I give this program show the event number, although previously I had been given but this time in form recursive, because previously I had been given about the iterative ...
ok with it, is how to create a recursive program to call itself, is made using a recursive function and selection, as opposed to just using the iterative looping ...
So, this is the source code of this program
#include <iostream>
#include<string>
using namespace std;
class angka_genap{
public:
angka_genap();
int genap_rekursif(int i);
private:
int i;};
angka_genap::angka_genap(){}
int angka_genap::genap_rekursif(int i){
if (i>20){}
else{if (i % 2==0) {
cout << i << endl; }
else{}
genap_rekursif(i+1);
}
}
int main(){
angka_genap x;
cout<<"\nShow the even number with recursive from 1 till 20\n";
x.genap_rekursif(1);
system("pause");
return 0;
}
0 comments:
Post a Comment