1 / 12

C++

C++. Budi Darma Stiawan. STRUKTUR PROGRAM. ATAP. BANGUNAN /TEMBOK. PONDASI. STRUKTUR PROGRAM. http://www.cplusplus.com/doc/tutorial/variables/. STRUKTUR PROGRAM. Header Global variable declaration Program Body : local variable, instruction. HEADER. #include < iostream.h >

ahmed-case
Download Presentation

C++

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. C++ Budi DarmaStiawan

  2. STRUKTUR PROGRAM ATAP BANGUNAN /TEMBOK PONDASI

  3. STRUKTUR PROGRAM http://www.cplusplus.com/doc/tutorial/variables/

  4. STRUKTUR PROGRAM • Header • Global variable declaration • Program Body : local variable, instruction

  5. HEADER • #include <iostream.h> • #include disebutpreprocessor directive. • preprocessor directive menyebabkanisidariiostream.hdibaca/disertakandalam file program • Iostream.h, conio.h, stdio.h, string.h, vector.h, dll

  6. VARIABLE DECLARATION (review) • Mempersiapkanruangandi memory untukmenyimpannilaitertentu. • Jenis-jenisnilai tipe data (data type) • CONTOH: • int NUMB=5; • “NUMB “ disebutdenganvaribel / identifier / objek • “NUMB” dihubungkandenganruangandi memory yang dipersiapkanuntukmenyimpannilaidengantipe datainteger (bilanganbulat)

  7. VARIABLE DECLARATION • Deklarasivariabel: [tipe_data] [nama_variabel]; • Inisialisasivariabel : Prosespemberiannilaiawalkedalamvariabelataukonstanta. [nama_variabel] = [nilai_variabel]; • Inisialisasivariabeldapat pula langsungdilakukanpadasaatpendeklarasiannya. [tipe_data] [nama_variabel] = [nilai_awal_variabel]; • konstantaadalahlokasipenyimpannilai data dimemori yang nilainyatidakdapatdiubah-diubahsepanjangpengeksekusian program. • Pemberiannilaipadasuatukonstantaharusdilakukanpadasaatkonstantadideklarasikan. const [tipe_data] [nama_konstanta] = [nilai_konstanta]; • Untukmendefinisikantipe data barudapatdigunakanperintahberikut: typedef [tipe_data_standar] [tipe_data_baru]

  8. TIPE DATA http://www.cplusplus.com/doc/tutorial/variables/

  9. VARIABLE NAME • Tidakbolehsamadenganperintah-perintah/kata-katakuncidalambahasa C/C++ (reserved words) break, case, catch, char, class, const, do, double, false, float, for, friend, goto, if, struct, switch, template, this, throw, true, try, typedef, while, dll. • Hanyabolehterdiriatashuruf, angka, ataugarisbawah/underscore (_). • Tidakbolehdiawalidenganangka. • Panjangnyamaksimal 32 karakter. • Namavariabelhendaknyamendeskripsikantujuanpenggunaanvariabeltersebut.

  10. PROGRAM BODY • Dalam C++ setiap program harusterdiridarisebuahfungsi yang disebut main(). • Semuapernyataandalamfungsi main()akandieksekusisaat program dijalankan. • Contoh: void main() { int NUMB = 0, a = 3, b = 5; NUMB = a + b; cout<<“jumlah a ditambah b = ”<<NUMB; }

  11. STATEMENT • Declaration statement  1 • Assignment statement  2 • Output statement  3 • Input Statement (cin >> a)

  12. CONTOH PROGRAM

More Related