menampilkan angka genap dari 25 sampai 70 secara rekursif

#include <iostream>
#include <string>

using namespace std;
class genap
{
friend ostream& operator<<(ostream&, genap&);
friend istream& operator>>(istream&, genap&);
   public :

void input();
void hitung();
void output();
private :
int x,y,hasil;

};
istream& operator>>(istream& o, genap& j){
cout<<“masukkan bilangan awal= “;
o>>j.x;
cout<<“masukkan bilangan akhir= “;
o>>j.y;
}

void genap::hitung(){

  if (x>=y)
{
cout << “Salah” << endl;   }
   else
{
while (!(x>=(y+1)))
{
hasil =x % 2;
if (hasil==0)
{
cout << “Hasil=”<< + x << endl;         }
  else
{
}
x =x+1;
}
}
}

void genap::output(){
cout<<“hasil=”<<hasil;
}
  int main(int argc, char *argv[])
{

genap a;

cin>>a;

a.hitung();

a.output();

system(“pause”);
   return 0;
}

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