Tugas C++ 1

nih tmn-tmn kampusku, yang mau copy tugas kampus C++, q taruh di sini aja, habisnya capek, di datengin terus ke kosan hehehehehehe, ga bawa oleh2 juga, emangnya enak di mintai tugas mulu, Capek Deh!!!!!!!!!!!!!!!!!!!!!

#include <iostream.h>
#include <conio.h>

class kalkulator
{ int x, y;
public :
int jml();
int kurang();
int kali();
float bagi();
void nilai(int z, int q);
};

void kalkulator::nilai(int z, int q)
{x=z;y=q;}
int kalkulator::jml()
{ return(x+y);}
int kalkulator::kurang()
{ return(x-y);}
int kalkulator::kali()
{ return(x*y);}
float kalkulator::bagi()
{ return(x/y);}

main()
{ kalkulator f,g,h,i;
f.nilai(2,3);
g.nilai(4,5);
h.nilai(2,10);
i.nilai(9,5);
cout<<“\nPenjumlahan = “<<f.jml();
cout<<“\nPengurangan = “<<g.kurang();
cout<<“\nPerkalian = “<<h.kali();
cout<<“\nPembagian = “<<i.bagi();
getch();
}

%d blogger menyukai ini: