Rekursif

void cetak (int i, int n){
if(i<=n){
if(i%2==0 && i%5==0)
cout<<i<0){
if(n%2==0){
jumgenap += n;
}else{
jumganjil += n;
}
n–;
jumlah (n, jumgenap, jumganjil);
}else{
cout<<"Jumlah Genap ="<<jumgenap<<endl;
cout<<"Juymlah Ganjil ="<<jumganjil<<endl;
}
}

int main(int argc, char *argv[])
{
jumlah(100,0,0);
system("PAUSE");
return EXIT_SUCCESS;
}

Iklan

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s