Rabu, 04 April 2012

ALPRO DERETAN BILANGAN GENAP 25-70


FLOWCHART>OUTPUT C++>>CODING C++

CODING C++

#include <cstdlib>
#include <iostream>

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

public :
void proses();

private :
int a;
char *hasil;
};


istream& operator >>(istream& in, Kab& masuk){
cout<<"Masukkan Tahun : ";in>>masuk.a;
}

ostream& operator <<(ostream& out, Kab& keluar){
out<< "Tahun "<<keluar.a <<" adalah "<<keluar.hasil;
}

void Kab::proses(){
if(a%400==0 && a>0)
hasil = " Tahun kabisat ";
else
hasil = " Bukan tahun kabisat ";
}

int main (){
Kab x;
cin >> x;
x.proses();
cout<<x<<endl;

    system("PAUSE");
    return 0;
}



Tidak ada komentar:

Posting Komentar