Welcome to my site

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. ed ut perspiciatis unde omnis iste.

" Small is the number of people who see with their own eyes, think with their own minds and feel with their own hearts " (Albert Hermann Einstein)

= contact me at ndre@engineer.com or click on my facebook badge =

Media Penyimpanan Magnetik



Di Amerika Serikat, Pemerintah federal selalu memimpin dalam penggunaan peralatan pemrosesan data. Mesin pons atau kartu berlubang pertama digunakan di Bureau of the Cencus pada tahun 1890, dan komputer produksi masal pertama, yaitu Remington Rand UNIVAC I, digunakan oleh agen tersebut pada tahun 1951 sedangkan instalasi yang menandai awal penggunaan komputer dalam pemrosesan data bisnis baru dimulai pada tahun 1954 oleh General Electric. Hal ini tentunya merambat kepada kebutuhan akan media penyimpanan yang sederhana.
pada tahun 1967, IBM (International Bussiness Machines) menugaskan devisi media penyimpanannya untuk menciptakan sebuah system yang sederhana untuk meloading microcode kedalam mainframe 370. Pada tahun 1971, Dibawah pimpinan Alan shugart dan para teknisi di IBM berhasil mengembangkan floppy disk yang pertama. Pada saat pertama ditemukan namanya bukan floppy disk, melainkan memory disk. Floppy disk diambil dari kata “floppy” yang berarti fleksibel, muncul karena memory disk tersebut yang sangat fleksibel.
Pada tahun 1984, Apple computer memilih format disk produksi Sony tersebut untuk dipasangkan di computer Macintosh yang akhirnya menjadi format standar di Amerika. 

Penyimpanan magnetic
(bahasa Inggris: Magnetic disk) merupakan piranti penyimpanan sekunder yang paling banyak dijumpai pada sistem komputer modern. Pada saat disk digunakan, motor drive berputar dengan kecepatan yang sangat tinggi. Ada sebuah read−write head yang ditempatkan di atas permukaan piringan tersebut. Permukaan disk terbagi atas beberapa track yang masih terbagi lagi menjadi beberapa sektor. Cakram fixed−head memiliki satu head untuk tiap−tiap track, sedangkan cakram moving−head (atau sering dikenal dengan nama cakram keras ) hanya memiliki satu head yang harus dipindah−pindahkan untuk mengakses dari satu track ke track yang lainnya.

Pengertian Floppy Disk 

Floppy disk(disket) terbuat dari cakram tipis, fleksibel yang dilapisi bahan yang bersifat magnetik dan terbungkus atau dilindungi oleh plastik. kebanyakan floppy disk hanya mampu menampung data sekitar 1-2Mb saja, tetapi sekarang floppy disk dapat menyimpan data hingga 1 Gb. meskipun kecepatan akses datanya lebih lambat dari pada harddisk dan lebih rentan terhadap kerusakan permukaan disknya, floppy disk dulu sangat disukai karena harganya yang lebih murah dari pada removable disk lainnya dan dapat ditulis berkali-kali.
Ada juga pengertian yang lain, Floppy disk adalah 3. 5 inci, dengan shell terbuat dari plastik keras, paling sering hitam atau abu-abu, tetapi juga datang dalam berbagai warna. Bagian depan disk memiliki label dan sepotong tipis logam persegi panjang, yang digunakan untuk membaca dan menulis data, muncul di tengah atas. Bagian belakang disk juga plastik dan mengandung logam kecil lingkaran di tengah-tengah mengandung dua lubang kecil, yang memungkinkan untuk dipahami dengan baik oleh floppy disk drive. Floppy disk sering datang dengan kotak plastik keras untuk melindunginya dari elemen.

1.Write-protec tab; 2. Hub; 3. Shutter; 4. Plastic housting; 5. Paper ring; 6. Magnetic disk; 7. Disk sector;

Sejarah Disket
Awal sejarah floppy disk pada tahun 1967, pada saat IBM (International Bussiness Machines) menugaskan devisi media penyimpanannya untuk menciptakan sebuah system yang sederhana untuk meloading microcode kedalam mainframe 370.
Pada tahun 1971, Dibawah pimpinan Alan shugart dan para teknisi di IBM berhasil mengembangkan floppy disk yang pertama. Pada saat pertama ditemukan namanya bukan floppy disk, melainkan memory disk. Floppy disk diambil dari kata “floppy” yang berarti fleksibel, muncul karena memory disk tersebut yang sangat fleksibel.
Pada tahun 1975, sebuah perusahaan yang bernama Borroughs Corporation mengembangkan prototipe floppy disk berukuran 5 inci. Mereka menginginkan ada sebuah alat yang dapat menggantikan floppy disk yang berukuran 5 inci. Namun, Borroughs Corporation memutuskan untuk tidak melanjutkan proyek ini.
Di tahun 1976, disket dan disk drive yang telah fleksibel telah dibuat oleh Alan Shugart atas permintaan perusahaan komputer Laboratories, yang menginginkan agar disk drive dan floppy disk ini dapat gunakan pada komputer desktop mereka. Kemudian para produsen komputer lainnya mengikuti cara ini.
Dan pada tahun 80-an, Berbagai ukuran disk ditawarkan oleh berbagai perusahaan. Dan masing-masing sistem komputer menggunakan formatnya sendiri-sendiri.
Pada tahun 1981, Sony memperkenalkan disknya yang berukuran 3,5 inci.
Pada tahun 1984, Apple computer memilih format disk produksi Sony tersebut untuk dipasangkan di computer Macintosh yang akhirnya menjadi format standar di Amerika.
Cakram liuk atau disket (bahasa Inggris: floppy disk) adalah sebuah perangkat penyimpanan data yang terdiri dari sebuah medium penyimpanan magnetis bulat yang tipis dan lentur dan dilapisi lapisan plastik berbentuk persegi atau persegi panjang.
Cakram liuk “dibaca” dan “ditulis” menggunakan kandar cakram liuk (floppy disk drive, FDD). Kapasitas cakram liuk yang paling umum adalah 1,44 MB (seperti yang tertera pada cakram liuk), meski kapasitas sebenarnya adalah sekitar 1,38 MB.
Mungkin buat mereka yang terlahir di era millenium akan merasa asing , apa itu “disket” atau “floppy disc”. Anak jaman sekarang mungkin lebih mengenal flash disk ketimbang floppy disk. Popularitas floppy disc terus menurun dan bisa dibilang punah karena tak lagi digunakan banyak orang. Produsen komputer pun mulai meniadakannya di PC dan laptop baru buatannya.
Perangkat disket yang dulu sangat populer sebagai media penyimpanan sudah mendekati ajalnya. Kedatangan perangkat penyimpanan baru seperti USB drive atau CD secara perlahan telah membunuh disket. Perangkat baru tersebut memiliki kapasitas jauh lebih besar dan harganya yang semakin murah.
Kebutuhan akan floppy disc pernah mengalami masa puncak pada pertengahan 1990-an saat hampir semua komputer menggunakan peralatan yang berkapasitas 1,44 MB tersebut. Namun, permintaan atas floppy disc terus menurun sejak berkembangnya CD-R, CD-RW, bahkan USB flash disc yang menawarkan kapasitas penyimpanan data jauh lebih besar
Meski masih ada yang memproduksi dan memakainya, disket kemungkinan akan segera jadi barang antik. Sony, yang pernah jadi produsen disket besar dunia, kini memutuskan untuk mengakhiri produksi disket, sama seperti berbagai perusahaan besar lain yang tidak lagi menjualnya. Terus menurunannya permintaan, membuat perusahaan pembuat floppy disc menghentikan produksinya.
“Kebanyakan konsumen yang masih tersisa adalah para pengguna peralatan lama di sektor pendidikan dan pusat riset,” kata Sony. Tahun lalu pasar floppy disc di jepang saja mencapai 12 juta buah dan Sony memasok sekitar 70 persennya.
Setelah menghentikan distribusi disket 3,5 Inch di berbagai belahan dunia, Sony tidak akan menjual lagi perangkat penyimpanan itu di negaranya, Jepang. Seluruh proses produksi bakal dihentikan mulai Maret tahun 2011. Dari TGdaily, Senin (26/4/2010), Sony termasuk perusahaan yang membantu kelahiran disket pada tahun 1981 dan mulai memasarkannya tahun 1983. Di masa jayanya tahun 2000, Sony sempat mengapalkan sampai 47 juta unit disket.

Magneto-optic disk
Magneto-optic disk adalah salah satu contoh dari removable disk. Teknologi penyimpanan data pada magneto-disk adalah dengan cara menyinari permukaan disk dengan sinar laser yang ditembakkan dari disk head. tempat yang terkena sinar laser ini kemudian digunakan untuk menyimpan bit data. untuk mengakses data yang telah disimpan, head mengakses data tersebut dengan bantuaan kerr effect. cara kerja kerr effect adalah ketika suatu sinar laser dipantulkan dari sebuah titik magnetik. palarisasinya akan diputar secara atau berlawanan dengan arah jarum jam, tergantung dari orientasi medan magnetiknya. rotasi inilah yang dibaca oleh head disk sebagai sebuah bit data
.
PERKEMBANGAN STORAGE
Dijaman dahulu surat ataupun berkas berkas disimpan secara analog. Dunia berkembang begitu cepat dan manusia selalu mencari cara bagaimana untuk mendapatkan yang terbaik, tercepat, memiliki ukuran yang lebih kecil dan termurah. Muncul lah media penyimpanan disini adalah secara digital. Yaitu dengan menggunakan komputer. Hal inilah yang menyebabkan perkembangan Storage semakin lama semakin baik dan signifikan. Berikut sejarah perkembangnnya:
 

1. Punch Card
Sejak tahun 1725 telah dirancang sebuah media untuk menyimpan data yang diperkenalkan oleh seorang tokoh bernama Basile Bouchon menggunakan sebuah kertas berforasi untuk menyimpan pola yang digunakan pada kain. Namun pertama kali dipatenkan untuk penyimpanan data sekitar 23 September 1884 oleh Herman Hollerith - sebuah penemuan yang digunakan lebih dari 100 tahun hingga pertengahan 1970. Contoh di sini adalah bagaimana sebuah punch card dapat berfungsi sebagai media penyimpanan, memiliki 90 kolom (90 column punch card), terjadi tahun 1972. Jumlah data yang tersimpan dalam media tersebut sangat kecil, dan fungsi utamanya bukanlah menyimpan data namun menyimpan pengaturan (setting) untuk mesin yang berbeda.
Sejak tahun 1725 telah dirancang sebuah media untuk menyimpan data yang diperkenalkan oleh seorang tokoh bernama Basile Bouchon menggunakan sebuah kertas berforasi untuk menyimpan pola yang digunakan pada kain. Namun pertama kali dipatenkan untuk penyimpanan data sekitar 23 September 1884 oleh Herman Hollerith - sebuah penemuan yang digunakan lebih dari 100 tahun hingga pertengahan 1970. Contoh di sini adalah bagaimana sebuah punch card dapat berfungsi sebagai media penyimpanan, memiliki 90 kolom (90 column punch card), terjadi tahun 1972. Jumlah data yang tersimpan dalam media tersebut sangat kecil, dan fungsi utamanya bukanlah menyimpan data namun menyimpan pengaturan (setting) untuk mesin yang berbeda.
Sejak tahun 1725 telah dirancang sebuah media untuk menyimpan data yang diperkenalkan oleh seorang tokoh bernama Basile Bouchon menggunakan sebuah kertas berforasi untuk menyimpan pola yang digunakan pada kain. Namun pertama kali dipatenkan untuk penyimpanan data sekitar 23 September 1884 oleh Herman Hollerith - sebuah penemuan yang digunakan lebih dari 100 tahun hingga pertengahan 1970. Contoh di sini adalah bagaimana sebuah punch card dapat berfungsi sebagai media penyimpanan, memiliki 90 kolom (90 column punch card), terjadi tahun 1972. Jumlah data yang tersimpan dalam media tersebut sangat kecil, dan fungsi utamanya bukanlah menyimpan data namun menyimpan pengaturan (setting) untukmesinyangberbeda.

2. Punch Tape
Seorang tokoh bernama Alexander Bain merupakan orang yang pertama kali mengetahui penggunaan paper tape yang biasanya digunakan untuk mesin faksimili dan mesin telegram (tahun 1846). Setiap baris tape menampilkan satu karakter, namun karena Anda dapat membuat fanfold dengan mudah maka dapat menyimpan beberapa data secara signifikan menggunakan punch tape dibandingkan dengan punch card.

3. Selectron Tube
Pada tahun 1946 RCA mulai mengembagkan Selectron Tube yang merupakan awal format memori komputer dan Selectron Tube terbesar berukuran 10 inci yang dapat menyimpan 4096 bits Harga satu buah tabung sangat mahal dan umurnya sangat pendek di pasaran.

4. Magnetic Tape
Pada tahun 1950-an magnetic tape telah digunakan pertama kali oleh IBM untuk menyimpan data. Saat sebuah rol magetic tape dapat menyimpan data setara dengan 10.000 punch card, membuat magnetic tape sangat populer sebagai cara menyimpan data komputer hingga pertengahan tahun 1980-an.Pada tahun 1950-an magnetic tape telah digunakan pertama kali oleh IBM untuk menyimpan data. Saat sebuah rol magetic tape dapat menyimpan data setara dengan 10.000 punch card, membuat magnetic tape sangat populer dan fenomenal sebagai sebuah cara menyimpan data pada computer kerja hingga pertengahan tahun 1980-an.

5. Compact Cassette
Compact Cassette merupakan salah satu bagian dari Magnetic Tape, dikarenakan sudah banyak dari kita yang telah memilikinya, hal itu menjadi bagian yang khusus. Compact Cassette diperkenalkan oleh Philips pada tahun 1963, namun tidak sampai tahun 1970 menjadi populer. Komputer, seperti ZX Spectrum, Commodore 64 dan Amstrad CPC menggunakan kaset untuk menyimpan data. Standar 90 menit Compact Cassette dapat menyimpan sekitar 700kB hingga 1MB dari data tiap sisinya. Jika disetarakan dengan DVD, maka data dalam Compact Cassette dapat dijalankan selama 281 hari.

6. Magnetic Drum
Magnetic Drum memiliki panjang 16 inci yang bekerja 12.500 putaran tiap menit. Media ini digunakan untuk menunjang komputer IBM 650 sekitar 10.000 karakter dari Memori Utama.

7. Floppy Disk
Pada tahun 1969, floppy disk pertama kali diperkenalkan.

Saat itu hanya bisa membaca (read-only), jadi ketika data tersimpan tidak dapat dimodifikasi maupun dihapus. Ukurannya 8 inch dan dapat menyimpan data sekitar 80kB. Empat tahun kemudian, floppy disk yang sama muncul dan dapat menyimpan data sebanyak 256kB. Selain itu, juga memiliki kelebihan yaitu merupakan kemampuan dapat ditulis kembali (writeable).
Pada tahun 1969, floppy disk pertama kali diperkenalkan. Saat itu hanya bisa membaca (read-only), jadi ketika data tersimpan tidak dapat dimodifikasi maupun dihapus. Ukurannya 8 inch dan dapat menyimpan data sekitar 80kB. Empat tahun kemudian, floppy disk yang sama muncul dan dapat menyimpan data sebanyak 256kB. Selain itu, memiliki kemampuan dapat ditulis kembali (writeable). Perkembangan selanjutnya, pada tahun 1990 lahir disk dengan ukuran 3 inci yang dapat menyimpan data sekitar 250 MB, atau biasa disebut juga Zip disk.

8. World’s first hard drive
Tanggal 13 September 1956, komputer IBM 305 RAMA dalam kondisi tidak terselubungi. Komputer tidak mengalami perubahan sejak dapat menyimpan data sekitar 4.4 MB (setara dengan 5 milyar karakter) – saat itu sudah menjadi hal yang menakjubkan. Data tersimpan dalam 50 buah Magnetic Diks yang berukuran 24 inci. Lebih dari 1000 sistim dibangun dan diproduksi pada akhir tahun 1961. IBM mengeluarkan seharga $3,200 per bulan untuk memproduksi komputer.

9. Hard drive
Hard drive masih diproduksi di bawah pengembangan yang tetap (konstan). Hitachi Deskstar 7K yang Anda lihat pada gambar di bawah adalah hard drive pertama kali yang dapat menyimpan data 500GB “ setara dengan 120.000 World™s first hard drive IBM 305 RAMAC. Hal ini cenderung tiap tahun kita dapat memperoleh drive yang dapat menyimpan data secara cepat dengan harga yang lumayan terjangkau dan bisa dikatakan  murah.

10. Laser Disk
Tahun 1958, Laser Disk ditemukan namun tidak sampai tahun 1972 untuk pertama kalinya Video Disk didemonstrasikan kepada publik. Enam tahun kemudian, yaitu tahun 1978, sudah tersedia di beberapa pasaran. Hal yang tidak mungkin menyimpan data pada disk, namun mereka dapat menyimpan data dalam bentuk video dan gambar secara signifikan dengan kualitas tinggi lebih canggih dari teknik pada VHS.

11. Compact Disk
Compact disk muncul bermula dari penemuan Laser Disk, namun berukuran lebih kecil. Dikembangkan oleh kerjasama antara SONY dan Philips pada tahun 1979 dan Compact Disk sangat berlimpah di pasaran pada tahun 1982. Sekarang tipe CD dapat menyimpan data sebesar 700MB.

12. DVD
DVD (Digital Versatile Disc atau Digital Video Disc) merupakan dasar dari CD menggunakan teknologi laser yang berbeda. Panjang gelombang laser menggunakan 780nm sinar inframerah (standar CD menggunakan 625 nm hingga 650nm sinar inframerah) yang membuatnya memungkinkan menyimpan data pada space yang sama. Dua lapisan DVD dapat menyimpan data sebesar 8.5 GB.

13. HD-DVD
HD DVD (singkatan dari High-Definition DVD) adalah sebuah format cakram optik berkepadatan tinggi yang didisain untuk menyimpan data termasuk video definisi tinggi.

Sejarah

Cakram HD DVD dirancang untuk menggantikan format DVD. HD DVD dapat menampung data sebanyak tiga kali data yang ditampung DVD (15 GB per lapis berbanding 4,7 GB). Standar HD DVD dikembangkan oleh Toshiba dan NEC. Pada 19 November 2003, DVD Forum turut mendukung HD DVD sebagai penerus standar definisi tinggi. Pada pertemuan tersebut disepakati untuk menggunakan nama HD DVD yang sebelumnya dinamai AOD (Advanced Optical Disc).
Di Consumer Electronics Show 2006, Microsoft mengumumkan bahwa akan ada perangkat eksternal tambahan berupa kandar HD DVD di konsol permainan Xbox 360, hal ini direalisasi pada November 2006. Pada ajang tersebut, perusahaaan-perusahaan yang mendukung format HD DVD juga mengatakan bahwa akan ada 200 judul film akan tersedia pada akhir tahun.
Sejak awal HD DVD telah terlibat dalam "perang format" video berdefinisi tinggi dengan Blu-ray yang dikembangkan Sony. Setelah beberapa perusahaan film dan peritel besar mulai mengakhiri dukungan terhadap format HD DVD ini pada awal 2008, pada 19 Februari 2008 Toshiba mengumumkan akan mengakhiri produksi dan pengembangan HD DVD sehingga secara langsung menyudahi perang format tersebut.

Spesifikasi teknis

Tipe media: cakram optik kepadatan tinggi Kode: VC-1, H.264, dan MPEG-2
Kapasitas: 15 GB (satu lapis) dan 30 GB (lapis ganda)
Mekanisme baca: 1x@36Mb/s & 2x@72Mb/s
Pengembang: DVD Forum
Penggunaan: Penyimpanan data termasuk video definisi tinggi

14. Blu-Ray Disc
Cakram Blu-ray (Inggris: Blu-ray Disc disingkat BD) adalah sebuah format cakram optik untuk penyimpanan media digital termasuk video definisi tinggi. Nama Blu-ray diambil dari laser biru-ungu yang digunakan untuk membaca dan menulis cakram jenis ini. Cakram Blu-ray dapat menyimpan data yang lebih banyak dari format DVD yang lebih umum karena panjang gelombang laser biru-ungu yang dipakai hanya 405 nm dimana lebih pendek dibandingkan laser merah, 650 nm yang dipakai DVD dan piringan kompak. Format saingan Blu-ray yaitu HD DVD juga menggunakan laser jenis yang sama. Cakram Blu-ray dapat menyimpan 25 GB pada setiap lapisannya dibandingkan dengan 4,7 GB pada DVD. Beberapa pabrik bahkan telah membuat cakram Blu-ray satu lapis dan dua lapis (50 GB) yang dapat ditulis ulang. Beberapa studio film yang mendukung format Blu-ray bahkan telah merilis atau mengumumkan akan merilis film pada cakram berkapasitas 50 GB.blue ray lebih pendek dari panjang gelombang laser memungkinkan untuk menyimpan lebih banyak informasi pada 12 cm CD / DVD ukuran disk. Minimum "spot size" di mana sebuah laser dapat terfokus dibatasi oleh difraksi, dan bergantung pada panjang gelombang dari cahaya dan kecepatan rana numerik dari lensa yang digunakan untuk fokus itu. Dengan penurunan panjang gelombang, meningkatkan kecepatan rana numerik 0,60-0,85 dan membuat penutup lapisan tipis agar terhindar dari efek optik yang tidak diinginkan, laser dapat difokuskan ke tempat yang lebih kecil. Hal ini memungkinkan lebih banyak informasi yang akan disimpan di daerah yang sama.
Cakram Blu-ray mirip dengan PDD, format cakram optik lainnya yang dikembangkan oleh Sony dimana sudah tersedia sejak 2004. PDD memilik kecepatan transfer data yang lebih tinggi. PDD lebih ditujukan untuk pemakaian data bisnis atau cadangan.
Cakram Blu-ray sekarang ini pernah terlibat dalam perang format dengan saingannya HD DVD yang dikembangkan Toshiba. Setelah beberapa perusahaan film dan peritel besar mulai mengakhiri dukungan terhadap format HD DVD pada awal 2008, pada 19 Februari 2008 Toshiba mengumumkan akan mengakhiri produksi dan pengembangan HD DVD sehingga secara langsung menyudahi perang format tersebut.

Spesifikasi teknis

Cakram Blu-ray dua lapis berkapasitas 50 GB dapat menampung video definisi tinggi (HD) berdurasi 9 jam atau video definisi standar (SD) berdurasi 23 jam. Secara rata-rata, sebuah cakram Blu-ray satu lapis dapat menampung video MPEG-2 definisi tinggi berdurasi 135 menit dengan bonus 2 jam dalam kualitas definisi standar. Versi dua lapis dapat menampung video definisi tinggi berdurasi 3 jam dengan bonus dalam kualitas standar berdurasi 9 jam.
Ukuran fisik
Kapasitas satu lapis
Kapasitas dua lapis
12 cm, satu sisi
25 GB (23.3 GiB)
50 GB (46.6 GiB)
8 cm, satu sisi
7.8 GB (7.3 GiB)
15.6 GB (14.6 GiB)

Profil
Spesifikasi BD-ROM mendefinisikan empat profil untuk pemutar cakram Blu-ray. Semua profil berbasis video diharuskan memiliki implementasi lengkap dari BD-J.
  • 1.0 - Ini merupakan profil dasar yang harus dipakai semua pemutar Blu-ray. Pemutar berbasiskan profil ini hanya membutuhkan 64 KB (0.064 MB) area penyimpanan data aplikasi. Semua pemutar kategori ini akan dianggap kuno setelah November 2007 ketika profil 1.1 menjadi standar baru karena pemutar 1.0 tidak akan bisa menangani semua fitur interaktif yang akan diusung oleh profil 1.1
  • 1.1 - Profil 1.1 menambahkan dekoder video tambahan (untuk PIP), audio tambahan dan tempat penyimpanan 256 MB. Produk yang dirilis setelah November 2007 harus kompatibel dengan profil ini.
  • 2.0 (BD-Live) - Profil 2 yang juga dikenal dengan BD-Live menambahkan fitur konektivitas jaringan sebagai fungsi standar dan meningkatkan tempat penyimpanan ke 1 GB.
  • Suara (audio) - Profil ini diperuntukkan bagi pemutar yang hanya memainkan suara saja dan tidak membutuhkan penyandi video atau BD-J.
KEKURANGAN DAN KELEBIHAN BEBERAPA STORAGE

Sebenarnya otak manusia sudah menjadi media panyimpanan yang paling sempurna, namun kadang manusia juga sering “lupa”, seperti halnya Storage yang ter-format, kehilangan data-data yang penting. Berikut kelebihan dan kekurangan dari jenis Storage:

• KELEBIHAN DAN KEKURANGAN HARD DISK:
KELEBIHAN:
- Kapasitas besar
- Pembacaan data lebih cepat.
- Relative tahan lama
- Storage yang cukup aman
KEKURANGAN:
- Harga relative mahal
- Rawan terjadi bad sector
- Bentuk fisik yang relative besar dan berat
- Motor listrik yang memiliki batas usia tertentu, rata-rata 700.000 jam penggunaan.
- Mudah rusak jika terkena benturan fisik.

• KELEBIHAN DAN KEKURANGAN FLASH DISK:
KELEBIHAN :
- Bentuk yang kecil hingga mudah dibawa.
- Harga relative murah.
KEKURANGAN:
- Karena bentuk yang kecil, hingga rawan hilang.
- Removable storage, hingga data rawan rusak.

• KELEBIHAN DAN KEKURANGAN DISKET:
KELEBIHAN:
- Dikenal umum sebagai media penyimpanan pada zamannya
- Dikenal sebagai media portable yang cukup murah pada zamannya.
- Adanya fitur write protection.
KEKURANGAN:
- Kapasitas kecil
- Tranfer data lambat
- Mudah rusak
- Tidak didukung oleh computer modern

Sumber :

Java versus C++


An important bond exists between C/C++ and Java. C is the parent language of both C++ and Java. James Gosling implemented the initial versions of Java using C++, but he also took the opportunity presented by Java’s unique language model to modify its structure and make it more programmer-friendly than C/C++.


One major innovation relates to memory management. In practical terms, Java prevents you from going into an operating system and telling it to reserve or in other ways use the memory of a specific machine. Java was designed to do this because memory management is one of the activities that most tends to anchor a program to specific operating systems. Java provides an additional advantage with respect to Internet applications: executables created with Java preserve the integrity of the operating system on which they run. To put it differently, when you develop a program for a browser, for example, with Java you can be confident that if a given Internet user opens a Java applet, the applet is not going to violate the security of the user’s system.

One major activity of memory management involves setting aside (allocating) memory used by the program. An object-oriented program often performs this memory-management task by creating a program component known as an object (an instance of a class). In Java, for example, the JDialog or JFrame classes allow you to create dialogs and windows. When such objects are created, they can bog down the performance of a computer if they are not also destroyed when they are no longer in use. Java takes care of such activity through what is generally known as automated cleanup or garbage collecting. When an object falls into disuse, Java cleans it up for you. You do not have to count and manage objects, as you do with C++.

Java also differs from C++ along the following lines:

·         There is no preprocessing of source files in Java.
·         In Java there is no split between the interface or header (.h) and the implementation (.cpp) file; there is only one source file (.java).
·         Everything in Java is an object in the form of a class. In C++, you can revert to C and start writing code that does not involve classes, even to the point of creating global variables. In Java, you cannot define global variables (values that exist outside a class).
·         Java has no autocasting of types; you have to be explicit.
·         Java has a simplified object model and patterns; there is no support for multiple inheritance, templates, or operator overloading.

For general application development, Java has far outdistanced C++ as the preferred language.
However, C++ still commands a strong position as a server-side programming language and in
the world of console game development. C++ programs execute much faster than Java programs, and C++ also provides programmers control over execution and memory. Such capabilities prove useful in some game-development contexts or contexts in which optimized performance is essential. Still, Java applications developed for general enterprise prevail. Java programs often perform better, have fewer bugs, and prove easier to develop and maintain. Moreover, there is no comprehensively unified enterprise or mobile development environment in C++. In this respect, the J2EE platform is the world’s standard for development of end-to-end enterprise information systems.

Thank you for visiting my site and hope some of this information can be useful for us all.
Source : Thomson Course Technology PTR, a division of Thomson Learning Inc. book of Java™ ME Game Programming second edition by John P. Flynt, Ph.D., and Martin J. Wells

Introduction to Object Oriented Programming with Java

There is a famous story about a professor who goes to meet a zen master inquiring about zen.
The zen master welcomes the professor to his house and they sit to have tea. The master starts pouring tea into the professor's tea cup and keeps pouring long after it has filled up. The professor watches it at first with curiousity but the master oblivously keeps pouring and then no longer able to restrain himself the professor speaks out "the cup is overfull. No more will go in" and then the master says "it is the same with your mind. You have filled it with prejudices and preconception, how then is it possible for me to show you zen?"

Similar is the case with OOP. When we learn this style of programming, we must give up all that we had learnt in the procedural languages like C, fortran etc. OOP is a refreshingly new style of programming and requires a whole new way of thinking to be implemented. What this new way is, we shall approach shortly.

Now consider the following scenario.
We have the following people from a community
Jerry- a team leader
Kate- a negotiator, and resource manager
Chirs- a software programmer
Dan- a senior software consultant
Mira- an accountant and steno
Zoe- an automobile engineer
Mike- an electronics expert

Of course there are other people in the community but these are the ones who shall be in our view for the present.
Excepting Zoe and Mike, all the rest make up a software firm that provides high end software solutions (including certain hardware) and of course as you might have guessed, Jerry leads the team.

Now what happens is that an automobile company apporaches Jerry and asks him if they would design and program a chip that would make their latest automobile a versatile and artificially intelligent, robust beast.

Of course Jerry is all too glad and consents. The company then hands over the blueprints of the car and all the design and implementation details.

Jerry gets in touch with Dan and Chris and hands over the details to them. He further asks them to hire the people they will require. He then goes to Kate and asks her to meet up with Chris and Dan and get them what they need at the best price.

Meanwhile Dan and Chris decide to hire (of course) Zoe and Mike (who are their friends) and call them up. The four team up and have a brainstorming session on how to go about with it. With Zoe and Mike's expert advice, Dan gets a good insight into the software and hardware requirements to resolve the problem at hand and suggests them to Chris.

Now Kate comes to Dan and Chris and ask them about their requirements. The two tell Kate about Zoe, Mike and all the stuff they'll need. Kate then goes to Zoe and Mike, negotiates for a good price and hires them. She then fetches the rest of the requirements from the company's regular store.

Now the four intellectuals sit together and in a months time, most of the desiging and planning is done, in another month, Mike gives the specially designed chip to the other three and leaves. His work is complete for now. The rest of them now go deeper into the intricate mapping between the software programming that needs to be done and the actual physical effect it has to have on the car. In a couple of months, the Mapping is ready and it is Zoe's turn to leave. The two are left with all they require to start programming the chip and with expert advices from Dan, Chris does a great job of it using certain detailed implementations of technologies X, Y and Z. In four months, the whole thing is ready. Now Chris and Dan sit together and make a detailed report of their product. They then call Mike and Zoe to help them complete the documentation especially things like why they chose the design/technologies they chose and about how the chip must be integrated with the automobile. And one fine day, its all ready.

The whole thing is then rechecked and submitted to Jerry. Jerry then asks Kate to sit with Mira and get the whole accounts updated and get him the final bill statements. Kate does this and gives Jerry the final bill. Jerry then goes through the thing, adds in some things like development charges, consultation fees, and all those things that will actually make up for their salary.

He then goes to the automobile company with the programmed chip and the documentation (which includes the manual) and submits them along with the bill. The engineers go through the whole thing, approve it and Jerry is paid. What goes on after that is more or less inconsequential to our interests here.

Ok, thats the whole thing. Now I'll ask you a few questions
1. When Jerry gives the blueprints to Chris and Dan, what does he ask them to do?
He asks them to design the required chip and hire the people they wanted right? Now tell me did he know what the final thing was going to be like? did he have any idea about what the guys were gonna do and give him? nopes, he just knew that all he was going to get was the "REQUIRED CHIP" and he didn't know what kind of people he was going to hire either. He just asked them to hire "REQUIRED PEOPLE"
Look at that! the leader doesnt know these things, but he still gets the work done.
What Jerry has done is in essence ABSTRACTION and things like "required chip" and "required people" are abstract items or quantities, for without specific information, they do not exist physically.
For example- there is no chip called required chip until I specify the brand and processor speed or put down all the configurations or make it so specific that there is no amibguity about what I want.

The main thing to remember about abstraction is, it gives a definition to what we are looking for- like a "dream ship" or a "perfect girl" but it never bothers to be specific because there are many things that would fit into what you are looking for and many of those would satisfy you. In the above scenario, there could have been several other chips that could suit the purpose, other than what Chris and Dan designed.

In fact the main PURPOSE of abstraction is to carve out a space within which we shall go about finding solutions for the problem at hand.

Let us take a deeper look into this
Alan feels something is missing in his life and wants to find the solution, so he meditates upon it and realises that he needs "PEACE OF MIND" <-there we got our abstract quantity
So basically, Alan figures that the problem has a solution in "PEACE OF MIND"
He then writes on a piece of paper.

PEACE OF MIND
IS
----------FREEDOM FROM WORRY
----------FREEDOM FROM FEAR
----------FREEDOM FROM THOUGHTS ABOUT PAST
----------FREEDOM FROM NOISE
----------FREEDOM FROM DESIRE
etc.
Then he writes
FREEDOM FROM WORRY
----------KNOWING THAT WHATEVER HAPPENS IS FOR THE BEST

FREEDOM FROM FEAR
----------KNOWING THAT THERE IS SOMEONE ABOVE TO TAKE CARE

FREEDOM FROM THOUGHTS ABOUT PAST
----------FORGIVING THOSE WHO MADE LIFE BAD FOR YOU

and so for the others
Can you see what is happening? Starting from an abstract quantity, Alan is moving to a CONCRETE solution to his problems.
After two to three levels further going down, Alan catches the points in his life where things were not going according to his definition of PEACE OF MIND, and could immediately correct it.
BY ABSTRACTING THE PROBLEM, THE SOLUTION COMES EASILY TO US
And that is the major use of abstraction. It makes solutions come to us with ease, and more importantly in a well-defined and structured manner.

And remember you can only ASK for an ABSTRACT QTY. and NEVER CREATE it. This principle we shall be using lots of times later, so keep this in mind.

Now lets get back to the first scenario.
Did Jerry KNOW how the thing was going to be done and that Chris and Dan had hired Mike and Zoe? Of course not, why would Chris and Dan bother Jerry (who's basically a management guy) about all the software, electronic and automobile engineering jargon? Jerry didn't need to know (period) Neither do the automobile company guys. And Zoe and Mike know nothing about how Chris and Dan programmed the chip.

That is called ENCAPSULATION- or in other words HIDING DATA & IMPLEMENTATION. But why? Firstly to keep things as independent as possible and secondly to avoid unnecessary butting in. In more software like words, to preserve reusability (by making it independent) and avoid data corruption and prevent illegal actions.

Consider tha fan regulator in your room. It is actually much more than that sleek knob that you see, instead it is a pretty complex circuit within and you get to see none of it. It exposes only two interfaces (here interface just means something that can interact) for manipulation. The two wires behind the board for power input and the knob for regulating output. Thats it. You don't need anything more to use it. This is a classic example of encapsulation. Imagine if the whole regulator were open, any tom would be able to tamper with it and maybe get you an electric shock or short circuit the whole power supply! Meditate on this, and you'll know why you need encapsulation.

I'm reminded of an incident in my life when I had to submit a presentation at school and I was taken ill. So I had asked my dad to do it for me just so that I could escape the fury of the teachers. And my dad was kinda busy but he said he'd do it. And sometimes I'd get delirious about whether the thing got completed or not. And one day when I caught my dad, I asked him how far is it complete? and he twitched his lips and said "Why do you worry? I've told you I'll do it and I'll do it, how I do it, and when, just don't bother about these." And I set my mind at rest.and sure enough, the thing was ready on time. Another example of encapsulation, and another use- it prevents unnecessary worry, just trust things to know how to take care of themselves.

The above two concepts were explained mainly as an introduction, the real thing in java, we shall when we get down to writing code.

Two other concepts that are part of OOP are Inheritance and Polymorphism.

These are very easy concepts to understand, the names themselves speak a good deal. We shall suffice ourselves with just an general understanding of the two, the more detailed and precise definitions we shall give later.

Isn't there something common between your dad and you? or your mom and you? if yes, then you probably Inherited those features/qualities from your parent.

Consider a Shape.
A Rectangle is a Shape
So is a Circle

Let us draw an abstract to less abstract chart of Shape

SHAPE (something with a boundary)
----------POLYGON
-----------------TRIANGLE
-----------------QUADRILATERAL
---------------------------PARALLELOGRAM
-----------------------------------------RHOMBUS
-----------------------------------------RECTANGLE
--------------------------------------------------SQUARE
-----------------PENTAGON
-----------------ETC.
----------CURVED SHAPES
-----------------ELLIPSE
----------------------CIRCLE
--------------------etc.

Can you see whats going on? A square is a rectangle and also a quadrilateral and also a polygon and also a shape. Any figure down the hierarchy is a more concrete shape- more importantly, they are all shapes. And since they are all shapes, everything that a shape has, they also have. Since a shape can be filled with color, so can any of polygon, circle etc. In other words, since these things are DERIVED from the basic BASE called SHAPE, they have ALL the properties of a shape. This is essentially INHERITANCE.

INHERITANCE is when less abstract classes (called the DERIVED CLASS) of a BASE class DERIVE ALL the properties and functionality of the Base class

A shape can also be rotated, therefore so can a rhombus or a triangle. But when we want to rotate a shape, we will have to do it depending on what shape it is exactly right? A circle is rotated about the axis and a rhombus around the diagonal. BUT, the BASIC OPERATION is ROTATE, and rotate is what we shall do. But again, it DEPENDS on what exact shape it is. Therefore a circle has a different WAY to ROTATE and so does a rhombus.

When different derived classes behave differntly when the same operation is performed, it is called POLYMORPHISM- i.e it is morphing (changing) in many ways (poly).

We shall stop with a funny kind of polymorphism but this is just for fun, the accurate version is the one above.

Every morning I go out for a walk and it happens that I come across quite a few people I know. What happens when you come across people you know? they probably greet you- now this is the way each of them greet me.

Uncle- hello sonny, how're you doing
Girlfriend- Heyyy (with a lil honey in her voice, and a wink) whats up dude
Friend- whats up buddy, whats your plan for today?
Close friend- Whats up *#$%& ( with a whack on the back - no offence intended)
Angry Classmate- (venom in his eyes) grrrr
The Colony Grouch- -sNoRt-

Well, they're all people, but because they're all different, they do the same thing (greet) in different ways. Thats polymorphism too!

created by Robinhood

C Lang (Introduce)

C Basics

Before we embark on a brief tour of C's basic syntax and structure we offer a brief history of C and consider the characteristics of the C language. In the remainder of the Chapter we will look at the basic aspects of C programs such as C program structure, the declaration of variables, data types and operators. We will assume knowledge of a high level language, such as PASCAL.
It is our intention to provide a quick guide through similar C principles to most high level languages. Here the syntax may be slightly different but the concepts exactly the same.
C does have a few surprises:
  • Many High level languages, like PASCAL, are highly disciplined and structured.
  • However beware -- C is much more flexible and free-wheeling. This freedom gives C much more power that experienced users can employ. The above example below (mystery.c) illustrates how bad things could really get.

History of C

The milestones in C's development as a language are listed below:
  • UNIX developed c. 1969 -- DEC PDP-7 Assembly Language
  • BCPL -- a user friendly OS providing powerful development tools developed from BCPL. Assembler tedious long and error prone.
  • A new language ``B'' a second attempt. c. 1970.
  • A totally new language ``C'' a successor to ``B''. c. 1971
  • By 1973 UNIX OS almost totally written in ``C''.

Characteristics of C

We briefly list some of C's characteristics that define the language and also have lead to its popularity as a programming language. Naturally we will be studying many of these aspects throughout the course.
  • Small size
  • Extensive use of function calls
  • Loose typing -- unlike PASCAL
  • Structured language
  • Low level (BitWise) programming readily available
  • Pointer implementation - extensive use of pointers for memory, array, structures and functions.
C has now become a widely used professional language for various reasons.
  • It has high-level constructs.
  • It can handle low-level activities.
  • It produces efficient programs.
  • It can be compiled on a variety of computers.
Its main drawback is that it has poor error detection which can make it off putting to the beginner. However diligence in this matter can pay off handsomely since having learned the rules of C we can break them. Not many languages allow this. This if done properly and carefully leads to the power of C programming.
As an extreme example the following C code (mystery.c) is actually legal C code.
#include <stdio.h>

main(t,_,a)
char *a;
{return!0<t?t<3?main(-79,-13,a+main(-87,1-_,
main(-86, 0, a+1 )+a)):1,t<_?main(t+1, _, a ):3,main ( -94, -27+t, a
)&&t == 2 ?_<13 ?main ( 2, _+1, "%s %d %d\n" ):9:16:t<0?t<-72?main(_,
t,"@n'+,#'/*{}w+/w#cdnr/+,{}r/*de}+,/*{*+,/w{%+,/w#q#n+,/#{l,+,/n{n+\
,/+#n+,/#;#q#n+,/+k#;*+,/'r :'d*'3,}{w+K w'K:'+}e#';dq#'l q#'+d'K#!/\
+k#;q#'r}eKK#}w'r}eKK{nl]'/#;#q#n'){)#}w'){){nl]'/+#n';d}rw' i;# ){n\
l]!/n{n#'; r{#w'r nc{nl]'/#{l,+'K {rw' iK{;[{nl]'/w#q#\
n'wk nw' iwk{KK{nl]!/w{%'l##w#' i; :{nl]'/*{q#'ld;r'}{nlwb!/*de}'c \
;;{nl'-{}rw]'/+,}##'*}#nc,',#nw]'/+kd'+e}+;\
#'rdq#w! nr'/ ') }+}{rl#'{n' ')# }'+}##(!!/")
:t<-50?_==*a ?putchar(a[31]):main(-65,_,a+1):main((*a == '/')+t,_,a\
+1 ):0<t?main ( 2, 2 , "%s"):*a=='/'||main(0,main(-61,*a, "!ek;dc \
i@bK'(q)-[w]*%n+r3#l,{}:\nuwloca-O;m .vpbks,fxntdCeghiry"),a+1);}
It will compile and run and produce meaningful output. Try this program out. Try to compile and run it yourself. Alternatively you may run it from here and see the output.
Clearly nobody ever writes code like or at least should never. This piece of code actually one an international Obfuscated C Code Contest http://reality.sgi.com/csp/iocc The standard for C programs was originally the features set by Brian Kernighan. In order to make the language more internationally acceptable, an international standard was developed, ANSI C (American National Standards Institute).

C Program Structure

A C program basically has the following form:
  • Preprocessor Commands
  • Type definitions
  • Function prototypes -- declare function types and variables passed to function.
  • Variables
  • Functions
We must have a main() function.


A function has the form:

type function_name (parameters)
  {
     local variables
 
     C Statements
 
   }

If the type definition is omitted C assumes that function returns an integer type. NOTE: This can be a source of problems in a program.
So returning to our first C program:


  /* Sample program */ 
 
  main()
     {
 
     printf( ``I Like C $\backslash$n'' );
     exit ( 0 );
 
     }
NOTE:
  • C requires a semicolon at the end of every statement.
  • printf is a standard C function -- called from main.
  • $\backslash$n signifies newline. Formatted output -- more later.
  • exit() is also a standard function that causes the program to terminate. Strictly speaking it is not needed here as it is the last line of main() and the program will terminate anyway.
Let us look at another printing statement:
printf(``.$\backslash$n.1$\backslash$n..2$\backslash$n...3$\backslash$n'');

The output of this would be:

    .
  .1
  ..2
  ...3

Variables

C has the following simple data types:




The Pascal Equivalents are:




On UNIX systems all ints are long ints unless specified as short int explicitly.

NOTE: There is NO Boolean type in C -- you should use char, int or (better) unsigned char.

Unsigned can be used with all char and int types.

To declare a variable in C, do:
   var_type list variables;

e.g. int i,j,k;
   float x,y,z;
   char ch;

Defining Global Variables

Global variables are defined above main() in the following way:-

          short number,sum;
   int bignumber,bigsum;
   char letter;
 
   main()
     {
 
     }

It is also possible to pre-initialise global variables using the = operator for assignment.

NOTE: The = operator is the same as := is Pascal.

For example:-


          float sum=0.0;
   int bigsum=0;
   char letter=`A';
 
   main()
     {
 
     }
This is the same as:-


          float sum;
   int bigsum;
   char letter;
 
   main()
     {
 
     sum=0.0;
     bigsum=0;
     letter=`A';
 
     }
...but is more efficient.

C also allows multiple assignment statements using =, for example:

          a=b=c=d=3;

...which is the same as, but more efficient than:


          a=3;
  b=3;
  c=3;
  d=3;
This kind of assignment is only possible if all the variable types in the statement are the same.
You can define your own types use typedef. This will have greater relevance later in the course when we learn how to create more complex data structures.
As an example of a simple use let us consider how we may define two new types real and letter. These new types can then be used in the same way as the pre-defined C types:


          typedef real float;
   typedef letter char;
 
Variables declared:
   real sum=0.0;
   letter nextletter;

Printing Out and Inputting Variables

C uses formatted output. The printf function has a special formatting character (%) -- a character following this defines a certain format for a variable:

    %c -- characters
   %d -- integers
   %f -- floats
   e.g. printf(``%c %d %f'',ch,i,x);

NOTE: Format statement enclosed in ``...'', variables follow after. Make sure order of format and variable data types match up.

scanf() is the function for inputting values to a data structure: Its format is similar to printf:

   i.e. scanf(``%c %d %f'',&ch,&i,&x);

NOTE: & before variables. Please accept this for now and remember to include it. It is to do with pointers which we will meet later (Section 17.4.1).

Constants

ANSI C allows you to declare constants. When you declare a constant it is a bit like a variable declaration except the value cannot be changed.
The const keyword is to declare a constant, as shown below:
int const a = 1;
const int a =2;
Note:
  • You can declare the const before or after the type. Choose one an stick to it.
  • It is usual to initialise a const with a value as it cannot get a value any other way.
The preprocessor #define is another more flexible (see Preprocessor Chapters) method to define constants in a program.
You frequently see const declaration in function parameters. This says simply that the function is not going to change the value of the parameter.
The following function definition used concepts we have not met (see chapters on functions, strings, pointers, and standard libraries) but for completenes of this section it is is included here:
void strcpy(char *buffer, char const *string)
The second argiment string is a C string that will not be altered by the string copying standard library function.

Arithmetic Operations

As well as the standard arithmetic operators (+ - * /) found in most languages, C provides some more operators. There are some notable differences with other languages, such as Pascal.
Assignment is = i.e. i = 4; ch = `y';
Increment ++, Decrement -- which are more efficient than their long hand equivalents, for example:-- x++ is faster than x=x+1.
The ++ and -- operators can be either in post-fixed or pre-fixed. With pre-fixed the value is computed before the expression is evaluated whereas with post-fixed the value is computed after the expression is evaluated.
In the example below, ++z is pre-fixed and the w-- is post-fixed:

          int x,y,w;
 
   main()
     {
 
     x=((++z)-(w--)) % 100;
 
     }

This would be equivalent to:


          int x,y,w;
 
   main()
     {
 
    z++;
    x=(z-w) % 100;
    w--;
 
     }
The % (modulus) operator only works with integers.

Division / is for both integer and float division. So be careful.

The answer to: x = 3 / 2 is 1 even if x is declared a float!!

RULE: If both arguments of / are integer then do integer division.

So make sure you do this. The correct (for division) answer to the above is x = 3.0 / 2 or x= 3 / 2.0 or (better) x = 3.0 / 2.0.

There is also a convenient shorthand way to express computations in C.

It is very common to have expressions like: i = i + 3 or x = x*(y + 2)

This can written in C (generally) in a shorthand form like this:
   $\mbox{{\em expr}}_{1} \: \mbox{{\em op}} \: = \:\mbox{{\em expr}}_{2}$

which is equivalent to (but more efficient than):
   $\mbox{{\em expr}}_{1} \: = \: \mbox{{\em expr}}_{1} \: \mbox{{\em
op}} \: \mbox{{\em expr}}_{2}$

So we can rewrite    i = i + 3 as i += 3

and    x = x*(y + 2) as x *= y + 2.

NOTE: that x *= y + 2 means x = x*(y + 2) and NOT x = x*y + 2.

Comparison Operators

To test for equality is ==

A warning:  Beware of using ``='' instead of ``=='', such as writing accidentally

   if ( i = j ) .....

This is a perfectly LEGAL C statement (syntactically speaking) which copies the value in "j" into "i", and delivers this value, which will then be interpreted as TRUE if j is non-zero. This is called assignment by value -- a key feature of C.

Not equals is: !=

Other operators < (less than) , > (grater than), <= (less than or equals), >= (greater than or equals) are as usual.

Logical Operators

Logical operators are usually used with conditional statements which we shall meet in the next Chapter.

The two basic logical operators are:

&& for logical AND, || for logical OR.

Beware & and | have a different meaning for bitwise AND and OR ( more on this later in Chapter 12).

Order of Precedence

It is necessary to be careful of the meaning of such expressions as  a + b * c

We may want the effect as either

   (a + b) * c

or

   a + (b * c)
All operators have a priority, and high priority operators are evaluated before lower priority ones. Operators of the same priority are evaluated from left to right, so that

   a - b - c
is evaluated as

   ( a - b ) - c

as you would expect.

From high priority to low priority the order for all C operators (we have not met all of them yet) is:

     ( )  [  ]  -> .
   !  $\sim$ - * & sizeof cast ++ -
         (these are right->left)
   * / %
   + -
   < <= >= >
   == !=
   &
   $\wedge$   |
   &&
   ||
   ?:        (right->left)
   = += -= (right->left)
   ,   (comma)
Thus
   a < 10 && 2 * b < c

is interpreted as
   ( a < 10 ) && ( ( 2 * b ) < c )
and

   a =
 
   b =
     spokes / spokes_per_wheel
     + spares;

as

   a =
 
   ( b =
     ( spokes / spokes_per_wheel )
     + spares
   );

Exercises

Write C programs to perform the following tasks.
Exercise 12270
Input two numbers and work out their sum, average and sum of the squares of the numbers.
Exercise 12271
Input and output your name, address and age to an appropriate structure.
Exercise 12272
Write a program that works out the largest and smallest values from a set of 10 inputted numbers.
Exercise 12273
Write a program to read a "float" representing a number of degrees Celsius, and print as a "float" the equivalent temperature in degrees Fahrenheit. Print your results in a form such as
100.0 degrees Celsius converts to 212.0 degrees Fahrenheit.
Exercise 12274
Write a program to print several lines (such as your name and address). You may use either several printf instructions, each with a newline character in it, or one printf with several newlines in the string.
Exercise 12275
Write a program to read a positive integer at least equal to 3, and print out all possible permutations of three positive integers less or equal to than this value.
Exercise 12276
Write a program to read a number of units of length (a float) and print out the area of a circle of that radius. Assume that the value of pi is 3.14159 (an appropriate declaration will be given you by ceilidh - select setup).
Your output should take the form: The area of a circle of radius ... units is .... units.
If you want to be clever, and have looked ahead in the notes, print the message Error: Negative values not permitted. if the input value is negative.
Exercise 12277
Given as input a floating (real) number of centimeters, print out the equivalent number of feet (integer) and inches (floating, 1 decimal), with the inches given to an accuracy of one decimal place.
Assume 2.54 centimeters per inch, and 12 inches per foot.
If the input value is 333.3, the output format should be:
333.3 centimeters is 10 feet 11.2 inches.
Exercise 12278
Given as input an integer number of seconds, print as output the equivalent time in hours, minutes and seconds. Recommended output format is something like
7322 seconds is equivalent to 2 hours 2 minutes 2 seconds.
Exercise 12279
Write a program to read two integers with the following significance.
The first integer value represents a time of day on a 24 hour clock, so that 1245 represents quarter to one mid-day, for example.
The second integer represents a time duration in a similar way, so that 345 represents three hours and 45 minutes.
This duration is to be added to the first time, and the result printed out in the same notation, in this case 1630 which is the time 3 hours and 45 minutes after 12.45.
Typical output might be Start time is 1415. Duration is 50. End time is 1505.
There are a few extra marks for spotting.
Start time is 2300. Duration is 200. End time is 100.

created by Dave Marshall

 
This Theme Modified by Kapten Andre based on Structure Theme from MIT-style License by Jason J. Jaeger