1 / 4

PERTEMUAN KE-10

PERTEMUAN KE-10. IF II UIN SGD. FUNGSI OVERLOADED. Fungsi yang memiliki nama yang sama , namun isi fungsi berbeda . Contoh : #include < iostream > using namespace std ; int operasi ( int a, int b) { return (a*b); } float operasi (float a, float b) { return (a/b); }

coral
Download Presentation

PERTEMUAN KE-10

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. PERTEMUAN KE-10 IF II UIN SGD

  2. FUNGSI OVERLOADED • Fungsi yang memilikinama yang sama, namunisifungsiberbeda. Contoh: #include <iostream> using namespace std; intoperasi(int a, int b) { return (a*b); } float operasi(float a, float b) { return (a/b); } intmain () { intx=5,y=2; float n=5.0,m=2.0; cout<< operasi(x,y); cout<< "\n"; cout<< operasi(n,m); cout<< "\n"; return 0; }

  3. FUNGSI REKRUSIF • Fungsirekrusif: fungsiygmemanggildirinyasendiri. Contoh: #include <iostream> using namespace std; long faktorial(long a) { if (a > 1) {return (a * faktorial(a-1));} else {return (1);} } intmain () { long a; cout<< “MasukkanAngka: "; cin>> a; cout<< a << "! = " << faktorial (a); return 0; }

  4. FUNCTION (PART II) • Buat program kali, bagi, tambah, kurang, akar, lebihbesarlebihkecil ,ganjilgenapdariinputan 2 angka. Menggunakanfungsi!!

More Related