Minggu, 24 April 2011

Contoh perulangan

  •  Perulangan pola naik : awal =1 , akhir = 4 , syarat akhir >= awal terpenuhi . Program mencetak bilangan 1 - 4.


for loop
while loop
do_while loop
#include <iostream.h>
main(){
int i;
for (i=1;i<=4;i++)
cout << “ ” <<i;
return 0;
}
#include <iostream.h>
main(){
int i=1;
while (i<=4){
cout<<” “ << i;
i++;
}
return 0;
}
#include <iostream.h>
main(){
int i=1;
do{cout<<” “<<i;
i++;
}while (i<=4);
return 0;
}

  •  Perulangan pola turun : awal =4 , akhir = 1 , syarat awal >= akhir terpenuhi . Program mencetak bilangan 4 - 1.


for loop
while loop
do_while loop
#include <iostream.h>
main(){
int i;
for (i=4;i>=1;i--)
cout << “ ” <<i;
return 0;
}
#include <iostream.h>
main(){
int i=4;
while (i>=4){
cout<<” “ << i;
i--;
}
return 0;
}
#include <iostream.h>
main(){
int i=1;
do{
cout<<” “<<i;
i--;
}while (i>=1);
return 0;
}




Perulangan


Ada 3 pertanyaan dalam perulangan C++ , Yaitu menggunakan struktur for,while dan do_while .Bentuk umum dari ketiga pertanyaan tersebut adalah sebagai berikut :

For
While
Do_while
for (i=awal; i<=akhir; i++)
aksi;
i=awal;
while (i<=akhir){
aksi
i++
}
i=awal;
do {
aksi;
i++;
}while(i<=akhir);

 Pola diatas adalah pola perulangan naik . ini ditunjukan dengan i++. Tentu saja syarat aksi dilaksanakan bila akhir >= awal. Namun bila dikehendaki pola turun bagian i++ diganti dengan i--, dan syarat menjadi awal >=akhir.

Akar-akar Persamaan Kuadrat

Rumus persamaan kuadrat adalah:

AX^2 + BX + C = 0
Untuk menentukan X1, X2 harus diketahui dilai Determinan (D), dimana:
D=B^2 – 4AC
Bila D>0, maka akan didapatkan X1, X2 berlainan nilai bisa nol, positif atau negatif
Bila D=0, maka akan diperoleh nilai X1 = X2 baik positif, negatif atau no.
Bila D<0, maka akan didapatkan nilai X1, X2 imajiner
Untuk menentukan X1 dan X2 adalah
X1,X1 = -b(+-)akar(b^2-4ac)/2a

Konfersi Bil. biner ke desimal

Bilangan biner merupakan bilangan yang berbasis dua, yaitu 0 dan 1. Bilangan biner umumnya digunakan dalam pemrograman mesin. Dengan demikian penguasaan bilangan biner khususnya dalam pemrograman komputer adalah suatu keniscayaan. Namun kita seringkali berhadapan dengan sistem bilangan desimal yang berbasis 10 yaitu 0,1,2,3,4,5,6,7,8 dan 9. Berikut ini akan dijelaskan kode program mengkonversi bilangan biner ke bilangan desimal.

Tabel konversi biner ke desimal.

Program nilai indeks


#include <iostream.h>
#include <conio.h>

void cetak_array(int A[], int n) {
    for (int i=0; i<n; i++)
    cout << "Nilai indeks ke-[" << i << "] adalah " << A[ i ] << endl;
    getch();
}

void main() {
    int A[10] = {1,2,3,4,5,6,7,8,9,10};
    int n = 10;
    cout << "Nilai array asal : ";
    cetak_array(A, n);
    cout << "Setelah dikurangi 1 menjadi : " << endl;
    for (int i=0; i<n; i++)
    cout << "Nilai indeks ke-[" << i << "] adalah " << A[ i ]-1 << endl;      
    getch();
    cout << "Nilai array dicetak kembali" << endl;
    cetak_array(A, n);
    cout << "Ternyata tidak berubah. Perhatikan perbedaannya " << endl;  
    for (int i=0; i<n; i++)
    cout << "Nilai indeks ke-[" << i << "] adalah " << A[ i ]-- << endl;      
    cout << "Nilai array dicetak kembali" << endl;
    cetak_array(A, n);
}










Android (Operating System )


        
      This article is about the operating system. For other uses, see Android (disambiguation).
Android Android robot.svg
Android screenshot.png
Home screen displayed by Samsung Nexus S with Google running Android 2.3 "Gingerbread"
Company / developer     Google Inc.,
Open Handset Alliance
Programmed in     C (core),[1] C++ (some third-party libraries), Java (UI)
Working state     Current
Source model     Free and open source software (3.0 is currently in closed development) [2]
Initial release     21 October 2008 (2008-10-21)
Latest stable release     Tablets:
3.0.1 (Honeycomb)[3]
Phones:
2.3.3 (Gingerbread) / 24 February 2011; 59 days ago (2011-02-24)[3]
Supported platforms     ARM, MIPS, Power, x86[4][citation needed]
Kernel type     Linux kernel
Default user interface     Graphical
License     Apache 2.0, Linux kernel patches are under GPL v2[5]
Official website     android.com

Android is a software stack for mobile devices that includes an operating system, middleware and key applications.[6][7] Google Inc. purchased the initial developer of the software, Android Inc., in 2005.[8] Android's mobile operating system is based on the Linux kernel. Google and other members of the Open Handset Alliance collaborated on Android's development and release.[9][10] The Android Open Source Project (AOSP) is tasked with the maintenance and further development of Android.[11] The Android operating system is the world's best-selling Smartphone platform.[12][13]

Android has a large community of developers writing applications ("apps") that extend the functionality of the devices. There are currently over 150,000 apps available for Android.[14][15] Android Market is the online app store run by Google, though apps can also be downloaded from third-party sites. Developers write primarily in the Java language, controlling the device via Google-developed Java libraries.[16]

The unveiling of the Android distribution on 5 November 2007 was announced with the founding of the Open Handset Alliance, a consortium of 80 hardware, software, and telecom companies devoted to advancing open standards for mobile devices.[17][18] Google released most of the Android code under the Apache License, a free software and open source license.[19]

The Android open-source software stack consists of Java applications running on a Java-based, object-oriented application framework on top of Java core libraries running on a Dalvik virtual machine featuring JIT compilation. Libraries written in C include the surface manager, OpenCore[20] media framework, SQLite relational database management system, OpenGL ES 2.0 3D graphics API, WebKit layout engine, SGL graphics engine, SSL, and Bionic libc. The Android operating system, including the Linux kernel, consists of roughly 12 million lines of code including 3 million lines of XML, 2.8 million lines of C, 2.1 million lines of Java, and 1.75 million lines of C++.

Operasi Sistem Android 

        Artikel ini adalah tentang sistem operasi. Untuk kegunaan lain, lihat Android (disambiguasi).Android robot.svgAndroid screenshot.pngHome screen ditampilkan oleh Samsung Nexus S dengan Google menjalankan Android 2.3 "Gingerbread"Perusahaan / pengembang Google Inc,Open Handset AllianceDiprogram dalam C (inti), [1] C + + (beberapa perpustakaan pihak ketiga), Jawa (UI)Kerja negara LancarSumber model Bebas dan perangkat lunak sumber terbuka (3.0 sedang dalam pengembangan ditutup) [2]Rilis 21 Oktober 2008 (2008/10/21)Tablet Terbaru rilis stabil:3.0.1 (Honeycomb) [3]Telepon:2.3.3 (Gingerbread) / 24 Februari 2011; 59 hari lalu (2011/2/24) [3]Platform yang didukung ARM, MIPS, Power, x86 [4] [rujukan?]Kernel Linux kernel tipeDefault antarmuka pengguna grafisLisensi Apache 2.0, patch kernel Linux berada di bawah lisensi GPL v2 [5]Situs web resmi android.com
Android adalah sebuah software stack untuk perangkat mobile yang mencakup sistem operasi, middleware dan aplikasi kunci [6] [7] Google Inc membeli pengembang awal dari perangkat lunak, Android Inc, pada tahun 2005.. [8] sistem operasi mobile Android didasarkan pada kernel Linux. Google dan anggota lain dari Open Handset Alliance berkolaborasi pada pengembangan Android dan lepaskan. [9] [10] Android Open Source Project (AOSP) bertugas dengan pemeliharaan dan pengembangan lebih lanjut Android [11] Sistem operasi Android adalah. dunia terlaris Smartphone platform. [12] [13]
Android memiliki komunitas besar pengembang menulis aplikasi ("aplikasi") yang memperluas fungsionalitas dari perangkat. Saat ini ada lebih dari 150.000 aplikasi yang tersedia untuk Android [14] [15] Android Market adalah toko aplikasi online yang dijalankan oleh Google, meskipun aplikasi juga dapat didownload dari situs pihak ketiga.. Pengembang menulis terutama dalam bahasa Jawa, mengendalikan perangkat melalui perpustakaan Jawa-dikembangkan Google. [16]
Pembukaan dari distribusi Android pada 5 November 2007 diumumkan dengan mendirikan Open Handset Alliance, sebuah konsorsium dari 80 hardware, software, dan perusahaan telekomunikasi yang ditujukan untuk memajukan standar terbuka untuk perangkat mobile. [17] [18] Google merilis paling dari kode Android di bawah Lisensi Apache, sebuah lisensi perangkat lunak bebas dan open source. [19]
Android software open-source stack terdiri dari aplikasi Java yang berjalan pada kerangka, aplikasi berbasis Java berorientasi objek di atas inti perpustakaan Jawa berjalan pada mesin virtual Dalvik menampilkan kompilasi JIT. Perpustakaan yang ditulis dalam C termasuk manajer permukaan, OpenCore kerangka [20] media, SQLite sistem manajemen basis data relasional, OpenGL ES 2.0 API grafis 3D, tata letak mesin WebKit, SGL mesin grafis, SSL, dan libc Bionic. Android sistem operasi, termasuk kernel Linux, terdiri dari sekitar 12 juta baris kode termasuk 3 juta baris XML, 2,8 juta baris C, 2,1 juta baris Jawa, dan 1,75 juta baris C + +.

Binary program

     
        Binary Programs are special programs consisting of pure object code. Binary programs are generally used as extensions to the BASIC interpreter, i.e. they implement one or more new BASIC statements. Actually, binary programs are simply machine language programs which were normally written in assembler and which can be used for any purpose, either as complete, self-contained program or as extension to the BASIC command set.
The approach how binary programs are used with BASIC program was different to the standard way how it was normally done in other BASIC dialects. One of the differences was, that HP9845 BASIC was quite well protected against any kind of machine address reference, including direct jumps to arbitrary machine addresses. Instead, HP provided means to load object code modules into memory and to add those routines together with the associated keywords to the BASIC instructions set which was already provided by the 9845 LPU firmware.

For a calling BASIC program, there was no difference whether the routine belonging to a special keyword was implemented permanently in ROM or temporarily loaded into R/W memory. Probably, the HP way was a bit more sophisticated and secure than the standard approach with the SYS and USR statements, since the ROM BASIC could be extended with real new instructions and it was'nt too easy to freeze the system accidentally through a jump to the wrong address. On the other side, through the complete abandonment of standard BASIC direct access statements like PEEK, POKE, ADR, SYS and USR, any access from within BASIC to the system resources was completely blocked.

Binary programs can also be used to implement complete applications. The TBIN system test binary is such an example, it works just like any other program, with the difference that it is completely in machine code. The functions provided by this program are driven my menus and keyboard short-cuts.

Binary programs had to meet some rules. The first rule was that it was not possible to specify a certain memory location where the object code should be installed. As a consequence, the object code module had to be designed with fully relocatable code. Another speciality was that each binary module had to have a defined header which holds information about the keyword(s) with which each module routine was invoked, the version information of the module, and the way how the statements can be syntaxed, listed and executed inside a BASIC program.

Binary modules could be saved and loaded in different ways, either alone (with the LOAD BIN command) or in combination with a BASIC program (see the Software Architecture section for more information about the the usage and structure of binary routines). All binary programs could include a special routine which was automatically executed after loading.

Since binary programs could be used to extend the set of statements which was implemented in firmware, it was the ideal way to implement some special functionality which couldn't be performed in BASIC. This includes even low level functionality, which is intentionally not provided by the normal BASIC implementation. One of the most useful example is the PHYREC binary program, which added the PHYREAD and the PHYWRITE statements, through which a direct sector access for any mass storage device was available. Other binary programs provided means to read standard SIF tapes or to access, test and diagnose selected memory areas. Because they - for certain applications - added very useful functionality to the standard BASIC, they are generally still of high interest. The funny side is, that keyword usage in BASIC programs was intentionally protected by 'secured lines' in many cases, in order to hide both purpose and usage for the normal user.

Special importance is due to the TBIN test binary program. This program was generally used by the service personnel in combination with the 09845-65520 Test ROM cartridge. It provides a number of highly useful diagnostics for exercising the different functional areas of a 9845 system and for the identification and isolation of defects.


Program binary


        Program Binary adalah program khusus yang terdiri dari kode obyek murni. program biner biasanya digunakan sebagai ekstensi untuk interpreter BASIC, yaitu mereka melaksanakan satu atau lebih laporan baru DASAR. Sebenarnya, program biner hanya program bahasa mesin yang biasanya ditulis dalam assembler dan yang dapat digunakan untuk tujuan apapun, baik sebagai lengkap, program mandiri atau sebagai perpanjangan perintah DASAR ditetapkan.

Pendekatan bagaimana program biner digunakan dengan program BASIC berbeda dengan cara standar bagaimana hal itu biasanya dilakukan dalam dialek BASIC lainnya. Salah satu perbedaan adalah, bahwa HP9845 DASAR cukup baik dilindungi terhadap segala jenis mesin referensi alamat, termasuk melompat langsung ke alamat mesin sewenang-wenang. Sebaliknya, HP menyediakan sarana untuk me-load modul kode objek ke dalam memori dan untuk menambah rutinitas mereka bersama-sama dengan kata kunci yang berhubungan dengan set instruksi DASAR yang sudah disediakan oleh firmware LPU 9845.

Untuk program BASIC panggilan, tidak ada perbedaan apakah rutin milik kata kunci khusus diimplementasikan secara permanen dalam ROM atau sementara dimuat ke R / W memori. Mungkin, cara HP adalah sedikit lebih canggih dan aman dibandingkan dengan pendekatan standar dengan laporan SYS dan USR, karena DASAR ROM dapat diperpanjang dengan instruksi baru yang nyata dan was'nt terlalu mudah untuk membekukan sistem tanpa sengaja melalui melompat ke alamat yang salah. Di sisi lain, melalui pengabaian laporan lengkap dari standar akses langsung DASAR seperti MENGINTIP, aduk, ADR, SYS dan USR, setiap akses dari dalam BASIC ke sumber daya sistem benar-benar diblokir.

program biner juga dapat digunakan untuk mengimplementasikan aplikasi lengkap. Sistem biner TBIN uji adalah seperti contoh, bekerja seperti program lain, dengan perbedaan bahwa itu benar-benar dalam kode mesin. Fungsi yang disediakan oleh program ini didorong menu saya dan shortcut keyboard.

program biner harus memenuhi beberapa aturan. Aturan pertama adalah bahwa tidak mungkin untuk menentukan lokasi memori tertentu di mana kode objek harus dipasang. Sebagai akibatnya, kode objek modul harus dirancang dengan kode sepenuhnya relokasi. Keistimewaan lain adalah bahwa setiap modul biner harus memiliki header pasti yang menyimpan informasi tentang kata kunci (s) yang masing-masing dengan rutin modul itu dipanggil, informasi versi dari modul, dan cara bagaimana laporan bisa syntaxed, terdaftar dan dijalankan dalam sebuah program BASIC.

modul biner dapat disimpan dan dimuat dengan cara yang berbeda, baik sendirian (dengan perintah LOAD BIN) atau dalam kombinasi dengan program BASIC (lihat bagian Perangkat Lunak Arsitektur untuk informasi lebih lanjut tentang penggunaan dan struktur rutinitas biner). Semua program biner dapat mencakup rutin khusus yang secara otomatis dijalankan setelah loading.

Karena program biner dapat digunakan untuk memperluas set pernyataan yang dilaksanakan di firmware, itu adalah cara ideal untuk mengimplementasikan beberapa fungsi khusus yang tidak dapat dilakukan di BASIC. Ini termasuk bahkan fungsionalitas tingkat rendah, yang sengaja tidak disediakan oleh pelaksanaan DASAR normal. Salah satu contoh yang paling berguna adalah program PHYREC biner, yang menambah PHYREAD dan laporan PHYWRITE, melalui mana sektor akses langsung untuk setiap perangkat penyimpanan massal yang tersedia. program biner lain yang disediakan berarti membaca standar SIF kaset atau untuk mengakses, menguji dan mendiagnosis daerah memori yang dipilih. Karena mereka - untuk aplikasi tertentu - menambahkan fungsionalitas yang sangat berguna bagi BASIC standar, mereka umumnya masih bunga yang tinggi. Sisi lucu adalah, bahwa penggunaan kata kunci dalam program BASIC sengaja dilindungi oleh 'baris dijamin' dalam banyak kasus, untuk menyembunyikan tujuan dan penggunaan baik untuk pengguna biasa.

Khusus pentingnya adalah karena program uji TBIN biner. Program ini umumnya digunakan oleh petugas servis dalam kombinasi dengan cartridge ROM 09845-65520 Test. Ini menyediakan sejumlah diagnostik yang sangat berguna untuk melaksanakan bidang fungsional yang berbeda dari sistem 9845 dan untuk identifikasi dan isolasi cacat.