SlideShare a Scribd company logo
1 of 10
FUNCTION / FUNGSI
Modular Programming
Sebuah program yang besar dibagi menjadi sejumlah modul kecil
(function). Setiap function mengerjakan tugas tertentu.
Keuntungan:
Rancangan Top down dengan pendekatan divide dan conquer.
Dapat dikerjakan dalam tim
Lebih mudah mengalkasikan kesalahan
Modifikasi dapat dilakukan tanpa menganggu program secara
keseluruhan
Mempermudah dokumentasi
Function
Standard library function, adalah fungsi funsi
standard yang sudah disediakan oleh C. Untuk
menggunakannya kita harus mencantumkan header
file dari fungsi tersebut. (dengan perintah #include)
Programmer / User Define Function, adalah fungsi
yang dibuat oleh programmer untuk digunakan
dalam program yang dibuat.
Standard Library Function
Contoh :
#include <stdio.h>
Beberapa fungsi yang terdapat dalam stdio.h :
printf()
scanf()
getchar()
gets()
puts()
Programmer-Defined Function
Dalam merancang sebuah function harus diperhatikan
sbb:
INPUT (data apa yang akan menjadi masukkan
fungsi)
PROSES (bagaimana algoritma yang akan digunakan
dalam fungsi tersebut)
OUTPUT (informasi apa yang akan dikembalikan
oleh fungsi kepada si pemanggil)
PROSES
INPUT
OUTPUT
Programmer-Defined Function
Penulisan fungsi dibagi atas :
Protototype (pendeklarasikan fungsi) yaitu kepala atau judul
fungsi (sebagai pengenal fungsi).
Definition yaitu penulisan fungsi secara lengkap.
Contoh :
int luas(int p, int l); // prototype
// definition
int luas(int p, int l) {
return p*l;
}
Contoh Penggunaan Fungsi
// Contoh Fungsi
#include <stdio.h>
#include <conio.h>
int penjumlahan(int a, int b) {
int r;
r=a+b;
return (r);
}
int main()
{ int z;
z=penjumlahan(5,3);
printf("Hasil penjumlahan = %d",z);
return 0;
}
Penjelasan Fungsi
Ketika program dieksekusi, yang dijalankan pertama
kali adalah fungsi main().
Terlihat jelas bahwa dalam main() terdapat variable z
dengan tipe data integer.
Setelah itu, fungsi penjumlahan dipanggil. Maka akan
terdapat proses pertukaran data sebagai berikut:
int penjumlahan(int a, int b)
z = penjumlahan ( 5 , 3 );
Penjelasan Fungsi
Maka setelah terjadi pengisian nilai, variable a akan terisi dengan nilai 5
dan variable b akan terisi dengan nilai 3.
Fungsi penjumlahan mendeklarasikan sebuah variable baru lagi (int r;)
dan
kemudian menjumlahkan nilai r=a+b; dengan hasil akhir variable r = 8.
return (r);
merupakan pengakhir fungsi penjumlahan dan memberikan hasil akhir
nilai r kepada fungsi yang memanggilnya (dalam hal ini fungsi
main()). Proses pengembalian nilai dapat digambarkan sebagai
berikut:
int penjumlahan(int a, int b)
8
z = penjumlahan ( 5 , 3 );
Nilai 8 hasil dari fungsi dikembalikan ke pemanggilnya.
END

More Related Content

What's hot

Algoritma dan Struktur Data - Sintaks C++
Algoritma dan Struktur Data - Sintaks C++Algoritma dan Struktur Data - Sintaks C++
Algoritma dan Struktur Data - Sintaks C++KuliahKita
 
Pengenalan Bahasa C
Pengenalan Bahasa CPengenalan Bahasa C
Pengenalan Bahasa Cguestaf3e8f4
 
Lapopran praktikum struktur data pertemuan 1 Tipe Data
Lapopran praktikum struktur data pertemuan 1  Tipe DataLapopran praktikum struktur data pertemuan 1  Tipe Data
Lapopran praktikum struktur data pertemuan 1 Tipe DataAdy Achirul
 
Function
FunctionFunction
Functionwindi1
 
Pertemuan 9 : Algoritma & Pemrograman
Pertemuan 9 : Algoritma & PemrogramanPertemuan 9 : Algoritma & Pemrograman
Pertemuan 9 : Algoritma & PemrogramanTri Retna
 
09 pd fungsi rekursif
09 pd fungsi rekursif09 pd fungsi rekursif
09 pd fungsi rekursifSofi Orient
 
Algoritma dan Struktur Data - Rekursif
Algoritma dan Struktur Data - RekursifAlgoritma dan Struktur Data - Rekursif
Algoritma dan Struktur Data - RekursifKuliahKita
 
Pemrograman C++ - Sintaks Dasar
Pemrograman C++ - Sintaks DasarPemrograman C++ - Sintaks Dasar
Pemrograman C++ - Sintaks DasarKuliahKita
 

What's hot (20)

Function
FunctionFunction
Function
 
Pertemuan 12 Structure
Pertemuan 12 StructurePertemuan 12 Structure
Pertemuan 12 Structure
 
Topik 10 Fungsi
Topik 10 FungsiTopik 10 Fungsi
Topik 10 Fungsi
 
Function c++
Function c++Function c++
Function c++
 
Algoritma
AlgoritmaAlgoritma
Algoritma
 
Algoritma dan Struktur Data - Sintaks C++
Algoritma dan Struktur Data - Sintaks C++Algoritma dan Struktur Data - Sintaks C++
Algoritma dan Struktur Data - Sintaks C++
 
Function
FunctionFunction
Function
 
Pengenalan Bahasa C
Pengenalan Bahasa CPengenalan Bahasa C
Pengenalan Bahasa C
 
Lapopran praktikum struktur data pertemuan 1 Tipe Data
Lapopran praktikum struktur data pertemuan 1  Tipe DataLapopran praktikum struktur data pertemuan 1  Tipe Data
Lapopran praktikum struktur data pertemuan 1 Tipe Data
 
Fungsi dan Prosedur
Fungsi dan ProsedurFungsi dan Prosedur
Fungsi dan Prosedur
 
Function
FunctionFunction
Function
 
Function
FunctionFunction
Function
 
Pertemuan II Function
Pertemuan II FunctionPertemuan II Function
Pertemuan II Function
 
Pertemuan 9 : Algoritma & Pemrograman
Pertemuan 9 : Algoritma & PemrogramanPertemuan 9 : Algoritma & Pemrograman
Pertemuan 9 : Algoritma & Pemrograman
 
09 pd fungsi rekursif
09 pd fungsi rekursif09 pd fungsi rekursif
09 pd fungsi rekursif
 
3 adp operator
3   adp operator3   adp operator
3 adp operator
 
Algoritma dan Struktur Data - Rekursif
Algoritma dan Struktur Data - RekursifAlgoritma dan Struktur Data - Rekursif
Algoritma dan Struktur Data - Rekursif
 
Function dalam PHP
Function dalam PHPFunction dalam PHP
Function dalam PHP
 
Pemrograman C++ - Sintaks Dasar
Pemrograman C++ - Sintaks DasarPemrograman C++ - Sintaks Dasar
Pemrograman C++ - Sintaks Dasar
 
Function pada PHP
Function pada PHPFunction pada PHP
Function pada PHP
 

Viewers also liked

Introductory maths analysis chapter 12 official
Introductory maths analysis   chapter 12 officialIntroductory maths analysis   chapter 12 official
Introductory maths analysis chapter 12 officialEvert Sandye Taasiringan
 
Introductory maths analysis chapter 14 official
Introductory maths analysis   chapter 14 officialIntroductory maths analysis   chapter 14 official
Introductory maths analysis chapter 14 officialEvert Sandye Taasiringan
 
Introductory maths analysis chapter 17 official
Introductory maths analysis   chapter 17 officialIntroductory maths analysis   chapter 17 official
Introductory maths analysis chapter 17 officialEvert Sandye Taasiringan
 
Introductory maths analysis chapter 16 official
Introductory maths analysis   chapter 16 officialIntroductory maths analysis   chapter 16 official
Introductory maths analysis chapter 16 officialEvert Sandye Taasiringan
 
Introductory maths analysis chapter 09 official
Introductory maths analysis   chapter 09 officialIntroductory maths analysis   chapter 09 official
Introductory maths analysis chapter 09 officialEvert Sandye Taasiringan
 
Introductory maths analysis chapter 11 official
Introductory maths analysis   chapter 11 officialIntroductory maths analysis   chapter 11 official
Introductory maths analysis chapter 11 officialEvert Sandye Taasiringan
 
Introductory maths analysis chapter 07 official
Introductory maths analysis   chapter 07 officialIntroductory maths analysis   chapter 07 official
Introductory maths analysis chapter 07 officialEvert Sandye Taasiringan
 
Introductory maths analysis chapter 00 official
Introductory maths analysis   chapter 00 officialIntroductory maths analysis   chapter 00 official
Introductory maths analysis chapter 00 officialEvert Sandye Taasiringan
 
Introductory maths analysis chapter 10 official
Introductory maths analysis   chapter 10 officialIntroductory maths analysis   chapter 10 official
Introductory maths analysis chapter 10 officialEvert Sandye Taasiringan
 
Introductory maths analysis chapter 15 official
Introductory maths analysis   chapter 15 officialIntroductory maths analysis   chapter 15 official
Introductory maths analysis chapter 15 officialEvert Sandye Taasiringan
 
Introductory maths analysis chapter 06 official
Introductory maths analysis   chapter 06 officialIntroductory maths analysis   chapter 06 official
Introductory maths analysis chapter 06 officialEvert Sandye Taasiringan
 
Introductory maths analysis chapter 05 official
Introductory maths analysis   chapter 05 officialIntroductory maths analysis   chapter 05 official
Introductory maths analysis chapter 05 officialEvert Sandye Taasiringan
 
Introductory maths analysis chapter 03 official
Introductory maths analysis   chapter 03 officialIntroductory maths analysis   chapter 03 official
Introductory maths analysis chapter 03 officialEvert Sandye Taasiringan
 
Introductory maths analysis chapter 13 official
Introductory maths analysis   chapter 13 officialIntroductory maths analysis   chapter 13 official
Introductory maths analysis chapter 13 officialEvert Sandye Taasiringan
 
Introductory maths analysis chapter 01 official
Introductory maths analysis   chapter 01 officialIntroductory maths analysis   chapter 01 official
Introductory maths analysis chapter 01 officialEvert Sandye Taasiringan
 
Introductory maths analysis chapter 04 official
Introductory maths analysis   chapter 04 officialIntroductory maths analysis   chapter 04 official
Introductory maths analysis chapter 04 officialEvert Sandye Taasiringan
 
Introductory maths analysis chapter 02 official
Introductory maths analysis   chapter 02 officialIntroductory maths analysis   chapter 02 official
Introductory maths analysis chapter 02 officialEvert Sandye Taasiringan
 
31350052 introductory-mathematical-analysis-textbook-solution-manual
31350052 introductory-mathematical-analysis-textbook-solution-manual31350052 introductory-mathematical-analysis-textbook-solution-manual
31350052 introductory-mathematical-analysis-textbook-solution-manualMahrukh Khalid
 

Viewers also liked (20)

01 01-algoritma
01 01-algoritma01 01-algoritma
01 01-algoritma
 
Introductory maths analysis chapter 12 official
Introductory maths analysis   chapter 12 officialIntroductory maths analysis   chapter 12 official
Introductory maths analysis chapter 12 official
 
Introductory maths analysis chapter 14 official
Introductory maths analysis   chapter 14 officialIntroductory maths analysis   chapter 14 official
Introductory maths analysis chapter 14 official
 
Introductory maths analysis chapter 17 official
Introductory maths analysis   chapter 17 officialIntroductory maths analysis   chapter 17 official
Introductory maths analysis chapter 17 official
 
03 i-o
03 i-o03 i-o
03 i-o
 
Introductory maths analysis chapter 16 official
Introductory maths analysis   chapter 16 officialIntroductory maths analysis   chapter 16 official
Introductory maths analysis chapter 16 official
 
Introductory maths analysis chapter 09 official
Introductory maths analysis   chapter 09 officialIntroductory maths analysis   chapter 09 official
Introductory maths analysis chapter 09 official
 
Introductory maths analysis chapter 11 official
Introductory maths analysis   chapter 11 officialIntroductory maths analysis   chapter 11 official
Introductory maths analysis chapter 11 official
 
Introductory maths analysis chapter 07 official
Introductory maths analysis   chapter 07 officialIntroductory maths analysis   chapter 07 official
Introductory maths analysis chapter 07 official
 
Introductory maths analysis chapter 00 official
Introductory maths analysis   chapter 00 officialIntroductory maths analysis   chapter 00 official
Introductory maths analysis chapter 00 official
 
Introductory maths analysis chapter 10 official
Introductory maths analysis   chapter 10 officialIntroductory maths analysis   chapter 10 official
Introductory maths analysis chapter 10 official
 
Introductory maths analysis chapter 15 official
Introductory maths analysis   chapter 15 officialIntroductory maths analysis   chapter 15 official
Introductory maths analysis chapter 15 official
 
Introductory maths analysis chapter 06 official
Introductory maths analysis   chapter 06 officialIntroductory maths analysis   chapter 06 official
Introductory maths analysis chapter 06 official
 
Introductory maths analysis chapter 05 official
Introductory maths analysis   chapter 05 officialIntroductory maths analysis   chapter 05 official
Introductory maths analysis chapter 05 official
 
Introductory maths analysis chapter 03 official
Introductory maths analysis   chapter 03 officialIntroductory maths analysis   chapter 03 official
Introductory maths analysis chapter 03 official
 
Introductory maths analysis chapter 13 official
Introductory maths analysis   chapter 13 officialIntroductory maths analysis   chapter 13 official
Introductory maths analysis chapter 13 official
 
Introductory maths analysis chapter 01 official
Introductory maths analysis   chapter 01 officialIntroductory maths analysis   chapter 01 official
Introductory maths analysis chapter 01 official
 
Introductory maths analysis chapter 04 official
Introductory maths analysis   chapter 04 officialIntroductory maths analysis   chapter 04 official
Introductory maths analysis chapter 04 official
 
Introductory maths analysis chapter 02 official
Introductory maths analysis   chapter 02 officialIntroductory maths analysis   chapter 02 official
Introductory maths analysis chapter 02 official
 
31350052 introductory-mathematical-analysis-textbook-solution-manual
31350052 introductory-mathematical-analysis-textbook-solution-manual31350052 introductory-mathematical-analysis-textbook-solution-manual
31350052 introductory-mathematical-analysis-textbook-solution-manual
 

Similar to 07 function 2

Materi kuliah 18 fungsi part 1
Materi kuliah 18   fungsi part 1Materi kuliah 18   fungsi part 1
Materi kuliah 18 fungsi part 1Budi Yono
 
Materi kuliah 18 fungsi part 1
Materi kuliah 18   fungsi part 1Materi kuliah 18   fungsi part 1
Materi kuliah 18 fungsi part 1kua
 
Pertemuan vi (Function Java)
Pertemuan vi (Function Java)Pertemuan vi (Function Java)
Pertemuan vi (Function Java)Putra Andry
 
Laporan praktikum modul vi
Laporan praktikum modul viLaporan praktikum modul vi
Laporan praktikum modul viDevi Apriansyah
 
Cara membuat fungsi dan prosedur pada java
Cara membuat fungsi dan prosedur pada javaCara membuat fungsi dan prosedur pada java
Cara membuat fungsi dan prosedur pada javaDevandy Enda
 
Pertemuan 12
Pertemuan 12Pertemuan 12
Pertemuan 12beiharira
 
5 adp fungsi & rekursi
5   adp fungsi & rekursi5   adp fungsi & rekursi
5 adp fungsi & rekursiChabil_Juniar
 
5.adp fungsi & rekursi
5.adp fungsi & rekursi5.adp fungsi & rekursi
5.adp fungsi & rekursiHardini_HD
 
5 adp fungsi & rekursi
5   adp fungsi & rekursi5   adp fungsi & rekursi
5 adp fungsi & rekursiAvenzz Venzz
 
5 adp fungsi & rekursi
5   adp fungsi & rekursi5   adp fungsi & rekursi
5 adp fungsi & rekursiFisma Ananda
 
5 adp fungsi & rekursi
5   adp fungsi & rekursi5   adp fungsi & rekursi
5 adp fungsi & rekursiFaisal Amir
 
4. pemrograman fungsi
4. pemrograman fungsi4. pemrograman fungsi
4. pemrograman fungsiRoziq Bahtiar
 

Similar to 07 function 2 (20)

Praktikum
PraktikumPraktikum
Praktikum
 
Fungsi
FungsiFungsi
Fungsi
 
Week 3-fungsi-header
Week 3-fungsi-headerWeek 3-fungsi-header
Week 3-fungsi-header
 
Materi kuliah 18 fungsi part 1
Materi kuliah 18   fungsi part 1Materi kuliah 18   fungsi part 1
Materi kuliah 18 fungsi part 1
 
Tugas sp algo
Tugas sp algoTugas sp algo
Tugas sp algo
 
Desain Top Down
Desain Top DownDesain Top Down
Desain Top Down
 
Materi kuliah 18 fungsi part 1
Materi kuliah 18   fungsi part 1Materi kuliah 18   fungsi part 1
Materi kuliah 18 fungsi part 1
 
Pertemuan vi (Function Java)
Pertemuan vi (Function Java)Pertemuan vi (Function Java)
Pertemuan vi (Function Java)
 
Laporan praktikum modul vi
Laporan praktikum modul viLaporan praktikum modul vi
Laporan praktikum modul vi
 
Modul pd
Modul pdModul pd
Modul pd
 
Cara membuat fungsi dan prosedur pada java
Cara membuat fungsi dan prosedur pada javaCara membuat fungsi dan prosedur pada java
Cara membuat fungsi dan prosedur pada java
 
Pertemuan 12
Pertemuan 12Pertemuan 12
Pertemuan 12
 
Function c++
Function c++Function c++
Function c++
 
5 adp fungsi & rekursi
5   adp fungsi & rekursi5   adp fungsi & rekursi
5 adp fungsi & rekursi
 
5.adp fungsi & rekursi
5.adp fungsi & rekursi5.adp fungsi & rekursi
5.adp fungsi & rekursi
 
5 adp fungsi & rekursi
5   adp fungsi & rekursi5   adp fungsi & rekursi
5 adp fungsi & rekursi
 
5 adp fungsi & rekursi
5   adp fungsi & rekursi5   adp fungsi & rekursi
5 adp fungsi & rekursi
 
5 adp fungsi & rekursi
5   adp fungsi & rekursi5   adp fungsi & rekursi
5 adp fungsi & rekursi
 
4. pemrograman fungsi
4. pemrograman fungsi4. pemrograman fungsi
4. pemrograman fungsi
 
Pertemuan 11 Fungsi (Function)
Pertemuan 11 Fungsi (Function)Pertemuan 11 Fungsi (Function)
Pertemuan 11 Fungsi (Function)
 

More from Evert Sandye Taasiringan (11)

04 if-ifelse-switch-break
04 if-ifelse-switch-break04 if-ifelse-switch-break
04 if-ifelse-switch-break
 
05 for-dowhile-while
05 for-dowhile-while05 for-dowhile-while
05 for-dowhile-while
 
06 nested
06 nested06 nested
06 nested
 
02 01-elemen
02 01-elemen02 01-elemen
02 01-elemen
 
02 02-operasi
02 02-operasi02 02-operasi
02 02-operasi
 
01 pseudocode
01 pseudocode01 pseudocode
01 pseudocode
 
01 algoritma
01 algoritma01 algoritma
01 algoritma
 
01 02-pseudocode
01 02-pseudocode01 02-pseudocode
01 02-pseudocode
 
Introductory maths analysis chapter 08 official
Introductory maths analysis   chapter 08 officialIntroductory maths analysis   chapter 08 official
Introductory maths analysis chapter 08 official
 
Pertemuan ke 1
Pertemuan ke 1Pertemuan ke 1
Pertemuan ke 1
 
Manajemen operasional ringkasan uas
Manajemen operasional ringkasan uas Manajemen operasional ringkasan uas
Manajemen operasional ringkasan uas
 

Recently uploaded

SBM_Kelompok-7_Alat dan Media Pembelajaran.pptx
SBM_Kelompok-7_Alat dan Media Pembelajaran.pptxSBM_Kelompok-7_Alat dan Media Pembelajaran.pptx
SBM_Kelompok-7_Alat dan Media Pembelajaran.pptxFardanassegaf
 
UNGGAH PEGANGAN LOKAKARYA DAN PENDAMPINGAN INDIVIDU DALAM KEGIATAN PEMBEKALAN...
UNGGAH PEGANGAN LOKAKARYA DAN PENDAMPINGAN INDIVIDU DALAM KEGIATAN PEMBEKALAN...UNGGAH PEGANGAN LOKAKARYA DAN PENDAMPINGAN INDIVIDU DALAM KEGIATAN PEMBEKALAN...
UNGGAH PEGANGAN LOKAKARYA DAN PENDAMPINGAN INDIVIDU DALAM KEGIATAN PEMBEKALAN...jumadsmanesi
 
SILABUS MATEMATIKA SMP kurikulum K13.docx
SILABUS MATEMATIKA SMP kurikulum K13.docxSILABUS MATEMATIKA SMP kurikulum K13.docx
SILABUS MATEMATIKA SMP kurikulum K13.docxrahmaamaw03
 
PPT TEKS TANGGAPAN KELAS 7 KURIKUKULM MERDEKA
PPT TEKS TANGGAPAN KELAS 7 KURIKUKULM MERDEKAPPT TEKS TANGGAPAN KELAS 7 KURIKUKULM MERDEKA
PPT TEKS TANGGAPAN KELAS 7 KURIKUKULM MERDEKARenoMardhatillahS
 
alat-alat liturgi dalam Gereja Katolik.pptx
alat-alat liturgi dalam Gereja Katolik.pptxalat-alat liturgi dalam Gereja Katolik.pptx
alat-alat liturgi dalam Gereja Katolik.pptxRioNahak1
 
Kelompok 1_Karakteristik negara jepang.pdf
Kelompok 1_Karakteristik negara jepang.pdfKelompok 1_Karakteristik negara jepang.pdf
Kelompok 1_Karakteristik negara jepang.pdfCloverash1
 
Kelompok 2 Karakteristik Negara Nigeria.pdf
Kelompok 2 Karakteristik Negara Nigeria.pdfKelompok 2 Karakteristik Negara Nigeria.pdf
Kelompok 2 Karakteristik Negara Nigeria.pdftsaniasalftn18
 
Materi Kelas Online Ministry Learning Center - Bedah Kitab 1 Tesalonika
Materi Kelas Online Ministry Learning Center - Bedah Kitab 1 TesalonikaMateri Kelas Online Ministry Learning Center - Bedah Kitab 1 Tesalonika
Materi Kelas Online Ministry Learning Center - Bedah Kitab 1 TesalonikaSABDA
 
TPPK_panduan pembentukan tim TPPK di satuan pendidikan
TPPK_panduan pembentukan tim TPPK di satuan pendidikanTPPK_panduan pembentukan tim TPPK di satuan pendidikan
TPPK_panduan pembentukan tim TPPK di satuan pendidikanNiKomangRaiVerawati
 
Kisi-kisi UTS Kelas 9 Tahun Ajaran 2023/2024 Semester 2 IPS
Kisi-kisi UTS Kelas 9 Tahun Ajaran 2023/2024 Semester 2 IPSKisi-kisi UTS Kelas 9 Tahun Ajaran 2023/2024 Semester 2 IPS
Kisi-kisi UTS Kelas 9 Tahun Ajaran 2023/2024 Semester 2 IPSyudi_alfian
 
Panduan Substansi_ Pengelolaan Kinerja Kepala Sekolah Tahap Pelaksanaan.pptx
Panduan Substansi_ Pengelolaan Kinerja Kepala Sekolah Tahap Pelaksanaan.pptxPanduan Substansi_ Pengelolaan Kinerja Kepala Sekolah Tahap Pelaksanaan.pptx
Panduan Substansi_ Pengelolaan Kinerja Kepala Sekolah Tahap Pelaksanaan.pptxsudianaade137
 
SKPM Kualiti @ Sekolah 23 Feb 22222023.pptx
SKPM Kualiti @ Sekolah 23 Feb 22222023.pptxSKPM Kualiti @ Sekolah 23 Feb 22222023.pptx
SKPM Kualiti @ Sekolah 23 Feb 22222023.pptxg66527130
 
PRESENTASI EEC social mobile, and local marketing.pptx
PRESENTASI EEC social mobile, and local marketing.pptxPRESENTASI EEC social mobile, and local marketing.pptx
PRESENTASI EEC social mobile, and local marketing.pptxPCMBANDUNGANKabSemar
 
5. HAK DAN KEWAJIBAN JEMAAH indonesia.pdf
5. HAK DAN KEWAJIBAN JEMAAH indonesia.pdf5. HAK DAN KEWAJIBAN JEMAAH indonesia.pdf
5. HAK DAN KEWAJIBAN JEMAAH indonesia.pdfWahyudinST
 
Jurnal Dwi mingguan modul 1.2-gurupenggerak.pptx
Jurnal Dwi mingguan modul 1.2-gurupenggerak.pptxJurnal Dwi mingguan modul 1.2-gurupenggerak.pptx
Jurnal Dwi mingguan modul 1.2-gurupenggerak.pptxBambang440423
 
Edukasi Haji 2023 pembinaan jemaah hajii
Edukasi Haji 2023 pembinaan jemaah hajiiEdukasi Haji 2023 pembinaan jemaah hajii
Edukasi Haji 2023 pembinaan jemaah hajiiIntanHanifah4
 
Kelompok 4 : Karakteristik Negara Inggris
Kelompok 4 : Karakteristik Negara InggrisKelompok 4 : Karakteristik Negara Inggris
Kelompok 4 : Karakteristik Negara InggrisNazla aulia
 
Buku Saku Layanan Haji Ramah Lansia 2.pdf
Buku Saku Layanan Haji Ramah Lansia 2.pdfBuku Saku Layanan Haji Ramah Lansia 2.pdf
Buku Saku Layanan Haji Ramah Lansia 2.pdfWahyudinST
 
adap penggunaan media sosial dalam kehidupan sehari-hari.pptx
adap penggunaan media sosial dalam kehidupan sehari-hari.pptxadap penggunaan media sosial dalam kehidupan sehari-hari.pptx
adap penggunaan media sosial dalam kehidupan sehari-hari.pptxmtsmampunbarub4
 
PUEBI.bahasa Indonesia/pedoman umum ejaan bahasa Indonesia pptx.
PUEBI.bahasa Indonesia/pedoman umum ejaan bahasa Indonesia pptx.PUEBI.bahasa Indonesia/pedoman umum ejaan bahasa Indonesia pptx.
PUEBI.bahasa Indonesia/pedoman umum ejaan bahasa Indonesia pptx.aechacha366
 

Recently uploaded (20)

SBM_Kelompok-7_Alat dan Media Pembelajaran.pptx
SBM_Kelompok-7_Alat dan Media Pembelajaran.pptxSBM_Kelompok-7_Alat dan Media Pembelajaran.pptx
SBM_Kelompok-7_Alat dan Media Pembelajaran.pptx
 
UNGGAH PEGANGAN LOKAKARYA DAN PENDAMPINGAN INDIVIDU DALAM KEGIATAN PEMBEKALAN...
UNGGAH PEGANGAN LOKAKARYA DAN PENDAMPINGAN INDIVIDU DALAM KEGIATAN PEMBEKALAN...UNGGAH PEGANGAN LOKAKARYA DAN PENDAMPINGAN INDIVIDU DALAM KEGIATAN PEMBEKALAN...
UNGGAH PEGANGAN LOKAKARYA DAN PENDAMPINGAN INDIVIDU DALAM KEGIATAN PEMBEKALAN...
 
SILABUS MATEMATIKA SMP kurikulum K13.docx
SILABUS MATEMATIKA SMP kurikulum K13.docxSILABUS MATEMATIKA SMP kurikulum K13.docx
SILABUS MATEMATIKA SMP kurikulum K13.docx
 
PPT TEKS TANGGAPAN KELAS 7 KURIKUKULM MERDEKA
PPT TEKS TANGGAPAN KELAS 7 KURIKUKULM MERDEKAPPT TEKS TANGGAPAN KELAS 7 KURIKUKULM MERDEKA
PPT TEKS TANGGAPAN KELAS 7 KURIKUKULM MERDEKA
 
alat-alat liturgi dalam Gereja Katolik.pptx
alat-alat liturgi dalam Gereja Katolik.pptxalat-alat liturgi dalam Gereja Katolik.pptx
alat-alat liturgi dalam Gereja Katolik.pptx
 
Kelompok 1_Karakteristik negara jepang.pdf
Kelompok 1_Karakteristik negara jepang.pdfKelompok 1_Karakteristik negara jepang.pdf
Kelompok 1_Karakteristik negara jepang.pdf
 
Kelompok 2 Karakteristik Negara Nigeria.pdf
Kelompok 2 Karakteristik Negara Nigeria.pdfKelompok 2 Karakteristik Negara Nigeria.pdf
Kelompok 2 Karakteristik Negara Nigeria.pdf
 
Materi Kelas Online Ministry Learning Center - Bedah Kitab 1 Tesalonika
Materi Kelas Online Ministry Learning Center - Bedah Kitab 1 TesalonikaMateri Kelas Online Ministry Learning Center - Bedah Kitab 1 Tesalonika
Materi Kelas Online Ministry Learning Center - Bedah Kitab 1 Tesalonika
 
TPPK_panduan pembentukan tim TPPK di satuan pendidikan
TPPK_panduan pembentukan tim TPPK di satuan pendidikanTPPK_panduan pembentukan tim TPPK di satuan pendidikan
TPPK_panduan pembentukan tim TPPK di satuan pendidikan
 
Kisi-kisi UTS Kelas 9 Tahun Ajaran 2023/2024 Semester 2 IPS
Kisi-kisi UTS Kelas 9 Tahun Ajaran 2023/2024 Semester 2 IPSKisi-kisi UTS Kelas 9 Tahun Ajaran 2023/2024 Semester 2 IPS
Kisi-kisi UTS Kelas 9 Tahun Ajaran 2023/2024 Semester 2 IPS
 
Panduan Substansi_ Pengelolaan Kinerja Kepala Sekolah Tahap Pelaksanaan.pptx
Panduan Substansi_ Pengelolaan Kinerja Kepala Sekolah Tahap Pelaksanaan.pptxPanduan Substansi_ Pengelolaan Kinerja Kepala Sekolah Tahap Pelaksanaan.pptx
Panduan Substansi_ Pengelolaan Kinerja Kepala Sekolah Tahap Pelaksanaan.pptx
 
SKPM Kualiti @ Sekolah 23 Feb 22222023.pptx
SKPM Kualiti @ Sekolah 23 Feb 22222023.pptxSKPM Kualiti @ Sekolah 23 Feb 22222023.pptx
SKPM Kualiti @ Sekolah 23 Feb 22222023.pptx
 
PRESENTASI EEC social mobile, and local marketing.pptx
PRESENTASI EEC social mobile, and local marketing.pptxPRESENTASI EEC social mobile, and local marketing.pptx
PRESENTASI EEC social mobile, and local marketing.pptx
 
5. HAK DAN KEWAJIBAN JEMAAH indonesia.pdf
5. HAK DAN KEWAJIBAN JEMAAH indonesia.pdf5. HAK DAN KEWAJIBAN JEMAAH indonesia.pdf
5. HAK DAN KEWAJIBAN JEMAAH indonesia.pdf
 
Jurnal Dwi mingguan modul 1.2-gurupenggerak.pptx
Jurnal Dwi mingguan modul 1.2-gurupenggerak.pptxJurnal Dwi mingguan modul 1.2-gurupenggerak.pptx
Jurnal Dwi mingguan modul 1.2-gurupenggerak.pptx
 
Edukasi Haji 2023 pembinaan jemaah hajii
Edukasi Haji 2023 pembinaan jemaah hajiiEdukasi Haji 2023 pembinaan jemaah hajii
Edukasi Haji 2023 pembinaan jemaah hajii
 
Kelompok 4 : Karakteristik Negara Inggris
Kelompok 4 : Karakteristik Negara InggrisKelompok 4 : Karakteristik Negara Inggris
Kelompok 4 : Karakteristik Negara Inggris
 
Buku Saku Layanan Haji Ramah Lansia 2.pdf
Buku Saku Layanan Haji Ramah Lansia 2.pdfBuku Saku Layanan Haji Ramah Lansia 2.pdf
Buku Saku Layanan Haji Ramah Lansia 2.pdf
 
adap penggunaan media sosial dalam kehidupan sehari-hari.pptx
adap penggunaan media sosial dalam kehidupan sehari-hari.pptxadap penggunaan media sosial dalam kehidupan sehari-hari.pptx
adap penggunaan media sosial dalam kehidupan sehari-hari.pptx
 
PUEBI.bahasa Indonesia/pedoman umum ejaan bahasa Indonesia pptx.
PUEBI.bahasa Indonesia/pedoman umum ejaan bahasa Indonesia pptx.PUEBI.bahasa Indonesia/pedoman umum ejaan bahasa Indonesia pptx.
PUEBI.bahasa Indonesia/pedoman umum ejaan bahasa Indonesia pptx.
 

07 function 2

  • 2. Modular Programming Sebuah program yang besar dibagi menjadi sejumlah modul kecil (function). Setiap function mengerjakan tugas tertentu. Keuntungan: Rancangan Top down dengan pendekatan divide dan conquer. Dapat dikerjakan dalam tim Lebih mudah mengalkasikan kesalahan Modifikasi dapat dilakukan tanpa menganggu program secara keseluruhan Mempermudah dokumentasi
  • 3. Function Standard library function, adalah fungsi funsi standard yang sudah disediakan oleh C. Untuk menggunakannya kita harus mencantumkan header file dari fungsi tersebut. (dengan perintah #include) Programmer / User Define Function, adalah fungsi yang dibuat oleh programmer untuk digunakan dalam program yang dibuat.
  • 4. Standard Library Function Contoh : #include <stdio.h> Beberapa fungsi yang terdapat dalam stdio.h : printf() scanf() getchar() gets() puts()
  • 5. Programmer-Defined Function Dalam merancang sebuah function harus diperhatikan sbb: INPUT (data apa yang akan menjadi masukkan fungsi) PROSES (bagaimana algoritma yang akan digunakan dalam fungsi tersebut) OUTPUT (informasi apa yang akan dikembalikan oleh fungsi kepada si pemanggil) PROSES INPUT OUTPUT
  • 6. Programmer-Defined Function Penulisan fungsi dibagi atas : Protototype (pendeklarasikan fungsi) yaitu kepala atau judul fungsi (sebagai pengenal fungsi). Definition yaitu penulisan fungsi secara lengkap. Contoh : int luas(int p, int l); // prototype // definition int luas(int p, int l) { return p*l; }
  • 7. Contoh Penggunaan Fungsi // Contoh Fungsi #include <stdio.h> #include <conio.h> int penjumlahan(int a, int b) { int r; r=a+b; return (r); } int main() { int z; z=penjumlahan(5,3); printf("Hasil penjumlahan = %d",z); return 0; }
  • 8. Penjelasan Fungsi Ketika program dieksekusi, yang dijalankan pertama kali adalah fungsi main(). Terlihat jelas bahwa dalam main() terdapat variable z dengan tipe data integer. Setelah itu, fungsi penjumlahan dipanggil. Maka akan terdapat proses pertukaran data sebagai berikut: int penjumlahan(int a, int b) z = penjumlahan ( 5 , 3 );
  • 9. Penjelasan Fungsi Maka setelah terjadi pengisian nilai, variable a akan terisi dengan nilai 5 dan variable b akan terisi dengan nilai 3. Fungsi penjumlahan mendeklarasikan sebuah variable baru lagi (int r;) dan kemudian menjumlahkan nilai r=a+b; dengan hasil akhir variable r = 8. return (r); merupakan pengakhir fungsi penjumlahan dan memberikan hasil akhir nilai r kepada fungsi yang memanggilnya (dalam hal ini fungsi main()). Proses pengembalian nilai dapat digambarkan sebagai berikut: int penjumlahan(int a, int b) 8 z = penjumlahan ( 5 , 3 ); Nilai 8 hasil dari fungsi dikembalikan ke pemanggilnya.
  • 10. END