BAHASA PEMROGRAMAN PEMROGRAMAN KOMPUTER Bab 1 PENDAHULUAN Pemrograman
BAHASA PEMROGRAMAN / PEMROGRAMAN KOMPUTER Bab 1 PENDAHULUAN
Pemrograman • Algoritma : Tahapan-tahapan menyelesaikan suatu permasalahan • Pemrograman : Proses menterjemahkan tugas ke dalam kumpulan perintah untuk komputer agar komputer dapat menjalankan tugas tersebut.
Tahapan Pemrograman • Pendefinisian • Deskripsi masalah • Perancangan langkah-langkah untuk menyelesaikan permasalahan algoritma – Menggunakan flow chart – Menggunakan Pseudocode / Sandi Semu • Coding
Masalah A Pendefinisian Masalah Program Deskripsi Masalah Perancangan dan Pengkodean Pelaksanaan uji coba dengan komputer Program Siap pakai A
Masalah Pendefinisian Masalah A Pengkodean Program Deskripsi Masalah Perancangan Algoritma A Pelaksanaan uji coba dengan komputer Program Siap pakai
Pemrograman • Algoritma yang ditulis dalam bahasa pemrograman : Program • Proses pengubahan algoritma menjadi program : pengkodean • Setiap tahap bisa terjadi kesalahan : – Kesalahan Syntax compiler/interpreter – Kesalahan Logika
Pemrograman • Ada program yang di jalankan di komputer tanpa diterjemahkan lebih dahulu : dengan interpreter – BASIC – d. BASE
Mengapa Algoritma ? • Keterikatan Aturan syntax – Berpikir logika • Keternbatasan Kemampuan – COBOL pengolahan data dalam jumlah yang besar – FORTRAN Perhitungan
Mengapa Algoritma ? • Sifat Pemrograman itu sendiri : – – – Banyak pemikiran Ketelitian berlogika Penjabaran masalah secara rinci Kejelian Keuletan Kesabaran
Mengapa Algoritma ? • Kesulitan tersebut dapat diatasi dengan menggunakan bahasa lain yang bersifat umum dan lebih bebas : – bahasa alamiah (natural langunge) – sandi semu (pseudo-code) – bagan alir (flow chart) • memisahkan aktifitas perancangan algoritma dari pengkodean
Mengapa Algoritma ? • Bahasa alami kurang mampu menjabarkan langkah pemecahan persoalan secara: – terstruktur – rinci – tanpa keraguan makna berbeda jauh dari bahasa pemrograman
Mengapa Algoritma ? • Sandi semu (pseudo-code) Pilihan terbaik untuk menyatakan algoritma karena : – terstruktur – rinci – jelas
Mengapa Algoritma ? • Program yang efisien program yang membutuhkan memori yang sekecil-kecilnya dengan waktu pelaksanaan yang secepat-cepatnya
Algoritma Definisi : Langkah-langkah pemecahan suatu masalah atau pekerjaan, yang dinyatakan secara sistematis, rinci, dan jelas, sehingga bila dilaksanakan pada kondisi awal tertentu, akan berakhir dalam selang waktu terbatas dan menghasilkan keluaran seperti yang diharapkan.
Karakteristik Algoritma • Finiteness: – terminates after a finite number of steps • Definiteness: – rigorously and unambiguously specified • Input: – valid inputs are clearly specified • Output: – can be proved to produce the correct output given a valid input • Effectiveness: – steps are sufficiently simple and basic.
Algoritma • Algoritma – terstruktur – independen
Algoritma • Terstruktur: – Terdiri dari sejumlah langkah, blok, prosedur & fungsi – Satu pintu masuk dan satu pintu keluar – Aliran Kendali mengikuti pola tertentu – Mudah dikelola & dikembangkan
Algoritma • Independent – Tidak tergantung pada bahasa pemrograman tertentu
Algoritma • Algoritma terstruktur berarti terbentuk dari sejumlah langkah, blok, prosedur dan fungsi dengan satu pintu masuk dan satu pintu keluar • Menghindari penggunaan statemen GOTO
Algoritma • Keuntungan Membuat Algoritma – Mempermudah pemrograman – Pemrograman menjadi independen – Pemrograman modular – Implementasi dalam beberapa bahasa pemrograman
Algoritma • Strategi Pengembangan Algoritma – Deskripsi masalah – Pengembangan deskripsi secara bertahap
Algoritma • Permasalahan dibagi menjadi submasalah yang lebih mudah dikerjakan • Sub-masalah dibagi lagi menjadi sejumlah sub-masalah yang lebih kecil sampai menjadi bagian yang mudah diselesaikan • Teknik ini disebut pemrograman modular atau top-down design
Contoh Algoritma • Masukkan 3 nilai yang ingin dijumlahkan • Jumlahkan nilai-nilai tersebut • Hasil penjumlahan dibagi dengan 3 • Cetak hasil yang diperoleh
Latihan Soal 1. Menampilkan bilangan 1 s/ 10 2. Menentukan apakah data yang dimasukkan adalah bilangan positif atau negatif 3. Tampilkan deret : -10, 8, -6, 4, -2, 0, 1, 4, 9, 16, 25 4. Tampilkan deret : 0, 1, 3, 6, 10, 15, 21, 28, 36, 45, 55
SELESAI BAB 1
- Slides: 26