C++ Mencari Ganjil dan Genap

#include <iostream>
#include <string>

using namespace std;
class jilnap{
private:
int a;
public:
int in();
int step();
};
int jilnap::in(){
cout<<“Masukan bilangan: “;
cin>>a;
}
int jilnap::step(){
if (a%2==0)
{cout<<“Bilangan “<<a<<” adalah bilangan genap”<<endl;}
else
{cout<<“Bilangan “<<a<<” adalah bilangan ganjil”<<endl;}
}
int main()
{
cout<<“=======Genap atau Ganjil?=======”<<endl;
jilnap x;
x.in();
x.step();
system(“pause”);
return 0;
}

Tinggalkan Balasan

Please log in using one of these methods to post your comment:

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