Nota (first)

  • 810 views
Uploaded on

NOTA UNTUK 3 DISEMBER 2013

NOTA UNTUK 3 DISEMBER 2013

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
810
On Slideshare
0
From Embeds
0
Number of Embeds
2

Actions

Shares
Downloads
12
Comments
0
Likes
1

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. 3 hours practical 1 hour theory NO FINAL EXAMINATION 100% ASSESMENT IN CLASS
  • 2. Topic 1 : Introductory Concepts Defination a. Programme - a program is a specific set of ordered operations for a computer to perform a. Programmer - a person who writes a program so that data may be processed by a computer - person who designs and writes and tests computer programs - who prepares or writes instructional programs for a computer c. Proggramming language- A programming language is an artificial language designed to express computations that can be performed by a machine, particularly a computer. Programming languages can be used to create programme that control the behavior of a machine, to express algorithms precisely, or as a mode of human communication -is a language designed to describe a set of consecutive actions to be executed by a computer. A programming language is therefore a practical way for us (humans) to give instructions to a computer.
  • 3. PROGRAMME • A computer programme (also a software programme, or just a program) is a sequence of instructions written to perform a specified task for a computer.[1] A computer requires programs to function, typically executing the program's instructions in a central processor.[2] The program has an executable form that the computer can use directly to execute the instructions. styled by: FARIZA ZAHARI.EC201 FUNDAMENTAL PROGRAMMING
  • 4. PROGRAMMER • A programmer, computer programmer or coder is someone who writes computer software. The term computer programmer can refer to a specialist in one area of computer programming or to a generalist who writes code for many kinds of software(C, C++, Java, Lisp, Delphi). styled by: FARIZA ZAHARI.EC201 FUNDAMENTAL PROGRAMMING
  • 5. ARAS BAHASA PENGATURCARAAN KOMPUTER COMPUTER PROGRAMMING LANGUAGE LEVEL TERBAHAGI KEPADA 4 JENIS • • • • BAHASA MESIN BAHASA HIMPUNAN BAHASA ARAS TINGGI BAHASA PENGATURCARAAN PEMBANGUNAN APLIKASI PANTAS DIVIDED IN TO 4 TYPES: • MACHINE LANGUAGE • ASSEMBLY LANGUAGE • HIGH LEVEL LANGUAGE • RAPID APLICATION DEVELOPER (RAD) styled by: FARIZA ZAHARI.EC201 FUNDAMENTAL PROGRAMMING
  • 6. Brief explaination Machine Language • • • Use own machine language Assemble binary numbers (1,0) No need translator Assembly Language • Easy language similar to human language Use short English wording Translator for this language called compiler • • High Level language • • Shorts codes used to settle multiple task Faster and easier to learn and write programming styled by: FARIZA ZAHARI.EC201 FUNDAMENTAL PROGRAMMING
  • 7. • • • • • Pascal, Basic, Cobol, Fortran, Ada, C, C++, JAVA Used GUI – Graphical User Interface Control window colour, size with simple and user friendly interfaces Interesting Programming Language with great visualization. Examples: Visual basic, Delphi, C++ Builder styled by: FARIZA ZAHARI.EC201 FUNDAMENTAL PROGRAMMING
  • 8. Jenis Pengaturcaraan • Berstruktur(Structured programming) – Pascal, C, COBOL, FORTRAN • Fungsian – Scheme, LISP • Berorientasikan objek (Object-oriented programming (OOP) ) – Java, C++ • Berasaskan logik – Prolog • Skrip – Perl, Visual Basic, Javascript
  • 9. Compare between the following types of programming STRUCTURED MODULAR OBJECT-ORIENTED Subset of procedural programming that enforces a logical structure on the program being written to make it more efficient and easier to understand and modify. Breaking down the design of a program into individual components (modules) that can be programmed and tested independently. It is a requirement for effective development and maintenance of large programs and projects. Programming language model organized around "objects" rather than "actions" and data rather than logic. Historically, a program has been viewed as a logical procedure that takes input data, processes it, and produces output data. styled by: FARIZA ZAHARI.EC201 FUNDAMENTAL PROGRAMMING
  • 10. A Brief of History of C • C was created by Dennis Ritchie at Bell Telephone Laboratories in 1972. styled by: FARIZA ZAHARI.EC201 FUNDAMENTAL PROGRAMMING
  • 11. PERKAKASAN KOMPUTER Komponen asas: 1) Peranti input 2) Peranti output 3) Unit pemprosesan pusat ( CPU ) 4) Ingatan utama ( RAM dan ROM ) 5) Ingatan bantu ( floppy A, cekera bermagnet ) styled by: FARIZA ZAHARI.EC201 FUNDAMENTAL PROGRAMMING
  • 12. styled by: FARIZA ZAHARI.EC201 FUNDAMENTAL PROGRAMMING
  • 13. styled by: FARIZA ZAHARI.EC201 FUNDAMENTAL PROGRAMMING
  • 14. TYPES OF ERROR IN PROGRAMMING 1) SYNTAX ERROR A collection of the rules for writing programs in a programming language is know as syntax. All program statements are written according do these rules. Syntax error is a type of error that occurs when a invalid statement is written in program. The compiler detects syntax errors and display error massage to describe the cause of error. A program containing syntax errors can`t be compiled successfully.
  • 15. EXAMPLES: • The statement terminator is missing at the end of statement like coma, semicolon ( ); etc. • A misspelled keyword is used in the program. • Any of the delimiters is missing. • Example: Typing "forr" insted of "for" is an example of syntax error.
  • 16. CSEB134 : BS/2008 17
  • 17. 2. Run-time errors • • • • An attempt to perform an invalid operation, detected during program execution. Occurs when the program directs the computer to perform an illegal operation, such as dividing a number by zero. The computer will executing the program, but no output display. And message box appears indicates the line where the error was detected 18
  • 18. 3. Logic Error/Design Error • An error caused by following an incorrect algorithm • Very difficult to detect - it does not cause runtime error and does not display message errors. • The only sign of logic error – incorrect program output • Can be detected by testing the program thoroughly, comparing its output to calculated results • To prevent – carefully desk checking the algorithm and written program before you actually type it CSEB134 : BS/2008 20
  • 19. 6 STAGE PROBLEM SOLVING (process of designing program) 1. 2. 3. 4. 5. 6. Defining and analyzing problems Planning of variables Drawing of flowchart Program writing Testing and debugging program Documentation of program Process of designing program can be divided into two phases 1. problem solving phase (1 through 3) 2. implementation phase (4 and 5) While in step 6, documentation is done throughout the process of designing program
  • 20. Defining and analyzing problems What is the problem? • Problem is an unsolved task that need to be settle with smart consideration • Perkara yang belum diselesaikan yang memerlukan penyelesaian dari pertimbangan atau kemahiran fikiran Penyelesaian • Proses menyelesaikan masalah yang melibatkan satu jujukan set tatacara yang perlu dilakukan mengikut susunan logik yang betul. Ia menggunakan pengetahuan bergantung kepada keupayaan memilih, menggunakan strategi, teknik dan alatan yang sesuai. styled by: FARIZA ZAHARI.EC201 FUNDAMENTAL PROGRAMMING
  • 21. Defining and analyzing problems • Langkah-langkah dalam pengaturcaraan : – Definisi dan kenalpasti masalah - Kenalpasti dan fahami masalah yang hendak diselesaikan i. Baca soalan dan kenalpasti serta fahami kehendak soalan ii. Buat analisa terhadap masalah dengan tentukan 3 perkara utama : * INPUT yang diperlukan * OUTPUT yang dikeluarkan * PROSES tentukan formula untuk dapatkan output dari input yang diberi INPUT PROSES (aturcara) OUTPUT
  • 22. Contoh Masalah Dahaga dan ingin minum teh tarik buatan sendiri • • • • Apa yang perlu dilakukan? Masak air.. Berapa banyak? Berapa orang nak minum? Pekat atau tidak??..berapa uncang teh? • Manis atau kurang manis?..berapa susu gula?? • Minum dalam mug atau cawan? • Sejuk atau panas?.. styled by: FARIZA ZAHARI.EC201 FUNDAMENTAL PROGRAMMING
  • 23. Contoh Penyelesaian.. The Tarik buatan sendiri 1. Kira berapa orang. • 1 Org minum 1 mug = 400ml • Air = Orang x 400ml 2. 2 orang perlu1 uncang • Uncang = orang /2 3. 1 uncang perlu 5 sudu susu pekat Susu = uncang x 5 styled by: FARIZA ZAHARI.EC201 FUNDAMENTAL PROGRAMMING
  • 24. Defining and analyzing problems • Langkah-langkah dalam pengaturcaraan : – Merancang pembolehubah - Pembolehubah ialah rujukan kepada lokasi memori - Pembolehubah dengan jenis data yang khusus menentukan saiz memori yang diperuntukan - Semua pembolehubah mesti diishtiharkan sebelum digunakan dalam aturcara
  • 25. Aturcara Berstruktur • Langkah-langkah dalam pengaturcaraan : – Rekabentuk aturcara - Lebih dikenali sebagai proses merekabentuk algoritma - Algoritma senarai langkah-langkah untuk selesaikan masalah - Dibuat sebelum pengkodan aturcara sebenar untuk pastikan kaedah penyelesaian masalah yang digunakan adalah betul - Terdapat 2 cara menulis algoritma : i. Kod pseudo Langkah-langkah penyelesaian masalah yang ditulis guna bahasa percakapan seharian ii. Carta alir Langkah-langkah penyelesaian masalah guna rajah-rajah tertentu
  • 26. Algorithms • Computing problems – All can be solved by executing a series of actions in a specific order • Algorithm: procedure in terms of – Actions to be executed – The order in which these actions are to be executed • Program control – Specify order in which statements are to be executed
  • 27. Algorithm a Ciri-ciri Kaedah • • • • • • • • Mempunyai input Hasilkan sekurangnya 1 output Tidak kabur Tepat dan selesaikan masalah Berkesan Bersifat am Pseudokod Carta Alir styled by: FARIZA ZAHARI.EC201 FUNDAMENTAL PROGRAMMING
  • 28. Contoh Algoritma Tentukan sama ada suatu nombor itu nombor genap atau ganjil Input: Suatu nombor bulat Output: Mesej “no genap” atan “no ganjil” Kira purata markah bagi kursus Pengaturcaraan C Input: i. Markah setiap pelajar ii. Bilangan Pelajar Output: Purata Markah Kira dan paparkan harga epal jika diberi kuantiti epal yang dibeli dalam kilogram dan harga sekilogram Input: i. Kuantiti epal yang dibeli dalam kilogram ii. Harga epalJAWAPANkilogram ) ( ringgit / Output: Harga epal ( dalam ringgit ) styled by: FARIZA ZAHARI.EC201 FUNDAMENTAL PROGRAMMING
  • 29. Pseudocode • Pseudocode – Artificial, informal language that helps us develop algorithms – Similar to everyday English – Not actually executed on computers – Helps us “think out” a program before writing it • Easy to convert into a corresponding C++ program • Consists only of executable statements 32
  • 30. Pseudokod Senarai langkah-langkah untuk selesaikan masalah Contoh : Menukar mentol yang terbakar mula Mengeluarkan mentol yang terbakar Gantikan dengan mentol baru tamat Adakah ia mencukupi untuk perlaksanaan komputer ? styled by: FARIZA ZAHARI.EC201 FUNDAMENTAL PROGRAMMING
  • 31. • Kod pseudo Contoh : Menukar mentol yang terbakar (terperinci) mula Letak tangga di posisi mentol terbakar Pilih mentol yang sesuai Naik tangga sehingga mencapai mentol yang terbakar Pusing mentol ikut arah lawan jam dan keluarkan mentol Muatkan mentol baru ditempat sepatutnya Pusingkan mentol ikut arah jam Turun tangga Letakkan kembali tangga tamat
  • 32. SIMBOL-SIMBOL CARTA ALIR SIMBOL GRAFIK MAKSUD MULA / TAMAT PROSES INPUT / OUTPUT SYARAT ALIRAN KAWALAN styled by: FARIZA ZAHARI.EC201 FUNDAMENTAL PROGRAMMING
  • 33. Carta Alir Mula Dapatkan x,y Jumlah = x + y Purata = (x+y)/2 Darab = x*y Cetak jumlah, purata dan darab Tamat styled by: FARIZA ZAHARI.EC201 FUNDAMENTAL PROGRAMMING
  • 34. Pseudokod • Masalah menentukan taraf lulus keputusan peperiksaan pelajar. • • • • • • Mula Dapatkan mata gred pelajar Tentukan samada pelajar lulus Jika matagred >=2.0 JAWAPAN laporkan ‘lulus’ Tamat styled by: FARIZA ZAHARI.EC201 FUNDAMENTAL PROGRAMMING
  • 35. Carta Alir Mula Dapatkan matagred Matagred >=2.0 JAWAPAN benar Cetak Lulus Tamat styled by: FARIZA ZAHARI.EC201 FUNDAMENTAL PROGRAMMING
  • 36. Carta Alir Mula Dapatkan matagred palsu Matagred >=2.0 Cetak ‘Gagal’ benar Cetak ‘Lulus’ Tamat styled by: FARIZA ZAHARI.EC201 FUNDAMENTAL PROGRAMMING
  • 37. Perlaksanaan • Proses menukarkan algoritma kepada bahasa pengaturcaraan. • Aturcara komputer ialah satu jujukan kenyataan menggunakan bahasa C++ untuk menyelesaikan sesuatu masalah. • Pengkompil akan menterjemahkan aturcara kepada bentuk yang boleh difahami oleh komputer • Pengkompil akan memaparkan ralat yang terkandung dalam aturcara. styled by: FARIZA ZAHARI.EC201 FUNDAMENTAL PROGRAMMING
  • 38. Perlaksanaan • Langkah-langkah dalam pengaturcaraan : – Menguji & menyahsilap aturcara - Aturcara yang telah siap dibina perlu diuji/dijalankan (run) untuk memastikan hasil output yang dikeluarkan adalah betul dan memenuhi kehendak pengguna - Menyahsilap (debugging) aturcara diuji dengan data-data yang sebenar - Ada kemungkinan output yang silap (ralat) mungkin terhasil daripada aturcara yang ditulis
  • 39. Perlaksanaan • Jenis ralat dalam pengaturcaraan • Ralat rekabentuk/ Ralat Logik – Terjadi semasa proses rekabentuk aturcara – Berpunca dari cara atau langkah penyelesaian masalah yang tidak betul • Ralat sintaks – Ralat yang dikesan dan mudah dibetulkan – Melibatkan kesilapan dalam menulis aturcara, seperti tertinggal simbol dsbnya. • Ralat masa jalanan(RUN-TIME ERROR) – Berpunca dari kemasukan data tidak mengikut arahan yang ditulis dalam aturcara cth: data jenis int tetapi data yang dimasuk jenis char styled by: FARIZA ZAHARI.EC201 FUNDAMENTAL PROGRAMMING
  • 40. Pengujian dan Pengesahihan • Uji dan sahkan keluaran yang dikehendaki benar • Proses untuk memastikan aturcara yang dibangunkan memenuhi keperluan pengguna styled by: FARIZA ZAHARI.EC201 FUNDAMENTAL PROGRAMMING
  • 41. Pendokumenan • Menyimpan semua data aturcara • Menyimpan aturcara yang ditulis • Menyimpan semua komponen yang terlibat dalam membangunkan dan menjalankan aturcara. • Melibatkan spesifikasi, penerangan tentang masalah, rumusan, pseudokod atau carta alir, dsbnya. styled by: FARIZA ZAHARI.EC201 FUNDAMENTAL PROGRAMMING