Minggu, 13 Januari 2013

PENGENALAN C++


PENGENALAN C++
1.1 SEJARAH C++
Bahasa C++ diciptakan oleh Bjarne Stroustrup di AT&T Bell
Laboratories awal tahun 1980-an berdasarkan C ANSI (American National
Standard Institute). Pertama kali, prototype C++ muncul sebagai C yang
dipercanggih dengan fasilitas kelas. Bahasa tersebut disebut C dengan kelas
( C wih class). Selama tahun 1983-1984, C dengan kelas disempurnakan
dengan menambahkan fasilitas pembebanlebihan operator dan fungsi yang
kemudian melahirkan apa yang disebut C++. Symbol ++ merupakan operator
C untuk operasi penaikan, muncul untuk menunjukkan bahwa bahasa baru ini
merupakan versi yang lebih canggih dari C.

Borland International merilis compiler Borland C++ dan Turbo C++.
Kedua compiler ini sama-sama dapat digunakan untuk mengkompilasi kode
C++. Bedanya, Borland C++ selain dapat digunakan dibawah lingkungan
DOS, juga dapat digunakan untuk pemrograman Windows.

Selain Borland International, beberapa perusahaan lain juga merilis
compiler C++, seperti Topspeed C++ dan Zortech C++.

Contoh Program C :

# include <stdio.h>
Main ( )
{
Char pesan [ ] = “Hai, C programmers !” ;
Printf (pesan) ;
Return 0 ;
}


Contoh Program C++ :


# include <iostream.h>
Main ( )
{
Char pesan [ ] = “Hai, C programmers !” ;
Cout << pesan ;
Return 0 ;
}


1.2 TENTANG C++
C++ diciptakan untuk mendukung pemrograman berorientasi pada
objek (Object Oriented Pragramming/OOP) yang tidak dimiliki C. sementara C
merupakan bahasa pemrograman terbaik dilingkungannya, bahasa ini tidak

T. Pemrograman Terstruktur 2 ( 1 ) Page 1 of 6


memiliki kemampuan OOP. Reputasi C tidak diragukan lagi dalam
menghasilkan program .EXE berukuran kecil, eksekusi yang cepat,
antarmuka (interfacing) yang sederhana dengan bahasa lain dan fleksibilitas
pemrograman. Apa yang membuat C tampak sukar dipelajari mungkin karena
tiadanya pemeriksaan tipe. Sebagai contoh, dapat mencampur bilangan bulat
dengan string untuk menghasilkan karakter. Namun, justru dsitu letak
fleksibilitas C, dapat mengolah data C sebebas mengolah data dalam bahasa
assembly.

1.3 BORLAND C++
Dibandingkan compiler C++ yang lain, Borland C++ memiliki
keunggulan terutama dalam hal kecepatan dan efisiensi kompilasi. Disamping
itu, Borland C++ mendukung beberapa system operasi yaitu DOS, Windows
16bit (Window 3.0) dan windows 32 bit (Windows NT). Meskipun demikian
compiler Borland C++ juga memiliki kelemahan bila dibandingkan compiler
C++ yang lain, misalnya : pemrograman dengan Borland C++ terutama yang
menyangkut tampilan jauh lebih sulit daripada pemrograman dengan
Microsoft Visual C++.

1.4 STRUKTUR BAHASA C++
Program C maupun C++ selalu tersusun dari 4 (empat) bagian utama, yaitu :

1. Bagian komentar yang ditandai dengan symbol // dan pasangan /* … */
2. Bagian pengarah compiler yang ditandai dengan symbol #
3. Bagian deklarasi
4. Bagian definisi
1.4.1 BAGIAN KOMENTAR
Program yang baik pada umumnya diberi komentar yang akan membantu
orang lain maupun pembuat program itu untuk memahami program yang
dibuat. Dalam C atau C++ setiap tulisan yang diapit oleh symbol /* … */ atau
setiap baris yang dimulai dengan symbol // dianggap komentar. C++ tidak
mengizinkan komentar bersarang ( nested comment), namun Borland C++
lebih fleksibel dalam hal ini.

Contoh C++ menggunakan komentar:

/* FIRST.CPP */
/* Program C++ pertamaku */
// Praproses
# include <iostream.h>
Void main ( )
{
Char pesan [ ] = “Hello, C++ programmers!” ;


T. Pemrograman Terstruktur 2 ( 1 ) Page 2 of 6


Cout << pesan ;
Return 0 ;
}


Pada Borland C++ dapat menggunakan komentar bersarang asalkan opsi cek
Nested comments pada menu Options/Compiler/Source dipilih.


1.4.2 BAGIAN PENGARAH KOMPILER
Contoh program C++ :

# include <iostream.h>

Void main ( )
{
Char pesan [ ] = “Hello, C++ programmers!” ;
Cout << pesan ;
Return 0 ;
}


Merupakan statement praprosesor, disebut juga pengarah compiler karena
berfungsi mengatur proses kompilasi.
IOSTREAM.H merupakan file program yang mengandung deklarasi kelaskelas
yang diperlukan oleh objek cout. File-file dengan ekstensi .H yang berisi
deklarasi fungsi-fungsi standar C ini, disebut secara umum sebagai file
header.
Beberapa pengarah compiler adalah :


1. # define
2. # include
3. # if, # else, # elif, # endif
4. # ifdef, # ifndef
1.4.2.1 PENGARAH KOMPILER # DEFINE
Untuk mendefinisikan suatu pengenal / konstanta yang nantinya akan
digantikan oleh praprosesor saat program dikompilasi.

Contoh Program :

# define SIZE 30
Int array [SIZE] ;
For (register int i = 0 ; i < SIZE ; i++)
{
Cout << array [ i ] ;
}


T. Pemrograman Terstruktur 2 ( 1 ) Page 3 of 6


1.4.2.2 PENGARAH KOMPILER # INCLUDE
Berfungsi membaca file program tertentu dan mengikutsertakan file tersebut
dalam proses kompilasi. Nama file yang dimaksud harus diapit symbol ‘ < ‘
dan ‘ > ‘ atau tanda kutip dua ( “ … “ ).

1.4.2.3 PENGARAH KOMPILER # IF, # ELSE, # ELIF, # ENDIF
Digunakan untuk memilih bagian program yang akan dikompilasi. Kompilasi
cari ini disebut kompilasi bersyarat dan program yang baik biasanya
memanfaatkan teknik ini.

1.4.2.4 PENGARAH KOMPILER # IFDEF, # IFNDEF
Digunakan juga dalam kompilasi bersyarat. # Ifdef dapat dibaca : ‘jika
didefinisikan’ dan # ifndef dapat dibaca : ‘jika tidak didefinisikan’.
Pengarah compiler ini sering digunakan untuk menandai bahwa suatu file
sudah diikutsertakan dalam kompilasi

1.4.3 BAGIAN DEKLARASI DAN DEFINISI
Semua program C pada dasarnya tersusun dari rangkaian
pemanggilan fungsi yang bekerja atas sekelompok data. Selain pemanggilan
fungsi, program C mengandung komponen lain yang disebut statement.
Statement C ada dua, yaitu : statement yang tidak dapat dieksekusi / non
executable ( bila dikompilasi tidak menghasilkan kode objek dan biasanya
digunakan untuk mengatur alur program), dan statement yang dapat
dieksekusi / executable (bila dikompilasi akan menghasilkan kode objek).
Setiap pemanggilan fungsi maupun statement executable dalam C harus
diakhiri dengan tanda titik koma ( ; ).

Contoh program C++:

# include <iostream.h>

Void main ( )

{
Char pesan [ ] = “Hello, C++ programmers!” ;
Cout << pesan ;
Return 0 ;
}


Dalam contoh program C++ diatas, Return merupakan contoh
statement executable yang menginstruksikan agar suatu fungsi
mengembalikan nilai balik tertentu. Contoh statement non executable adalah :
If, else, dan while.

T. Pemrograman Terstruktur 2 ( 1 ) Page 4 of 6


Main ( ) merupakan contoh fungsi, sedangkan pesan adalah contoh
data. Baik data maupun fungsi harus dideklarasikan. Data perlu
dideklarasikan agar compiler tahu berapa byte memori yang harus disediakan
untuk data yang bersangkutan, sedangkan fungsi perlu dideklarasikan agar
compiler dapat memeriksa ketepatan pemanggilan fungsi yang bersangkutan.
Deklarasi fungsi sering disebut pula prototype fungsi.

1.5 INPUT DAN OUTPUT
Di ANSI C, operasi input dan output dilakukan dengan menggunakan
fungsi-fungsi yang ada di header file stdio.h. contohnya untuk input dan
output ke layer monitor digunakan perintah seperti printf, scanf, putch, dsb.
Untuk input dan output ke file digunakan perintah seperti fread, fwrite, fputc,
dsb.

C++ mempunyai teknik input dan output yang baru, yaitu :
menggunakan stream. Header file untuk input dan output stream adalah
iostream.h dan beberapa file lain, seperti strstrea.h, fstream.h, dan
constrea.h.

Stream adalah suatu logika device (peralatan logika) yang
menghasilkan dan menerima informasi atau suatu wadah yang digunakan
untuk menampung keluaran dan menampung aliran data. Stream adalah
nama umum untuk menampung aliran data (contoh : file, keyboard, mouse),
maupun untuk keluaran (contoh : layer, printer).

Dalam C++ input berarti membaca dari stream dan output berarti
menulis ke stream.

Bentuk Umum Output operator :

Cout << ekspresi ;

Bentuk umum Input operator :

Cin >> variable ;

Dalam C++, menggunakan escape sequences untuk
merepresentasikan suatu karakter yang tidak terdapat dalam tradisional
symbol. Beberapa diantaranya :

\ n : linefeed / baris baru

\ b : back space

\ “ : petik ganda

T. Pemrograman Terstruktur 2 ( 1 ) Page 5 of 6


Contoh program versi ANSI C :

# include <stdio.h>
Void main ( )
{
Int x ;
Printf ( “Masukkan sebuah bilangan : \n” ) ;
Scanf ( “ %d ”, &x ) ;
Printf ( “Bilangan yang dimasukkan adalah %d\n “, x ) ;
}


Contoh program versi C++ :


# include <iostream.h>
Void main ( )
{
Int x ;
Cout << “Masukkan sebuah bilangan : ” << endl ;
Cin >> x ;
cout << “Bilangan yang dimasukkan adalah “ << x << endl ;
}


Contoh Program untuk input dan output :


# include <iostream.h>
Main ( )
{
Int a ;
Cout << “masukkan suatu bilangan :” ;
Cin >> a ;
Cout << “nilai tersebut ditambah 1 = ‘ << a+1 ;
Return 0 ;
}

T. Pemrograman Terstruktur 2 ( 1 ) Page 6 of 6 


6 komentar:

  1. If Brian's SEO didn't work, then he would never have been able to grow Backlinko to 100,000+ monthly readers, 100,000 email subscribers, and such a massive SEO brand with fewer than 40 blog posts. This online digital marketing course helps you learn how to navigate the entire digital marketing funnel, from attraction to retention, and gain the tools and knowledge to drive growth in your organization. Your strategy should articulate how you're going to deliver your products or services in ways that will satisfy your customers. Search engine optimization ( SEO ) involves the optimization of landing pages within your website to increase the number of visitors. Aim at producing content that brings out an emotional reaction from your audience, because many times people share content for emotional reasons. Youth marketing is any marketing strategy that's directed towards young people. A good digital marketing agency will never stop testing and reworking their strategy in order to boost your ROI and improve its overall efficacy.

    A digital marketing agency with qualified and experienced account managers will be able to improve your social media marketing results through detailed audience targeting, ensuring that your content reaches the correct people. Nidhi Dave is a content and brand strategist who ensures that a consistent brand message is delivered to the audience. Brand ambassadors are knowledgeable about your brand, and relate on a high level to its products and services.12 If your brand ambassador is selected carefully, not only will your company receive free publicity on the brand ambassador's network, it can create familiarity and interest in your company in related networks. With Remarketing lists for search ads (RSLA), Google shows your ad to visitors who have gone to your website and then do a subsequent search on for the keywords you're targeting. The bottom line is, content marketing can fetch you great results online if only it is done properly and reaching the right audience. There's something to be said for meeting with a potential customer face-to-face and discussing the role your products or services might play in his or her life. https://www.reviewengin.com/5-best-online-marketing-tactic-with-no-or-very-minimal-expenses-in-2019/

    BalasHapus
  2. Nutra Mini - It needs to be enforced by the authorities. A minority of people take the lead by researching and developing their Weight Loss. I feel as if I've found my way. I wonder why this took so long. This is because of you. They were working late into the night. I'm a big hitter. Now, now you might begin to get a bigger picture as this touches on Control X Keto Weight Loss. If you believe me or not, there it is.

    Keto Go Fit
    Drone Xtreme
    Ultraboost Wifi
    Toxifort
    Control X Keto Reviews
    Control X Keto Diet
    Keto Go Fit Diet
    Keto Go Fit Reviews

    BalasHapus

  3. For a fact, no one can ever say that to me in this way. You should only read this if you're ready for these feeble analysis of Gadgets. That was a rare moment. In the opinion of that writer I found Gadgets to be a blend of both Tech Products and doing it.


    AOL support number
    powervolt energy saver

    BalasHapus
  4. I am still working with Tech Products monthly even though gadgets is a gateway that leads to a new inspiration. Prospects are better for that thought today if you're able to do that. They're going to carry the torch.


    PowerPro Energy Saver
    Mosquitron
    Buzz B Gone

    BalasHapus
  5. This will allow you to secure and maintain placement in Google Maps to help extra people discover, contact, and visit your business. The web changes so fast that one year on-line equals about 5 years in the actual world. But the ideas of the way to begin and develop a profitable on-line business haven't changed at all. If you're simply beginning a small enterprise on-line, stick to this sequence. If you have been online awhile, do a quick review and see if there's a step you're neglecting, or never received around to doing within the first place.
    You can arrange a Facebook page or perhaps a podcast the place you can reach out to folks on the lookout for online coaching lessons. With a blog, you'll be able to sell all of these from one website and make the most money of any on-line enterprise idea on the market. Here is a list of the 107 greatest small business concepts to start in 2020.
    WordPress is the go-to platform for small companies and budding bloggers to begin an internet site of their own. If you might be nicely-versed in organising WordPress websites, use this ability to construct a enterprise. To hone your skills, you possibly can both take online wedding ceremony photography courses or be taught by studying this detailed guide. Here is the record of marriage ceremony images gear you have to start your wedding images business.This additionally means your audience has access to information whenever they want it. If they need questions answered or are in search of basic information, they can search online for the information and are available throughout your website. They have many alternatives to attach with your corporation and be taught extra.For instance, if it's a expertise friendly market it’s necessary to create digital storefronts. Direct promoting is the advertising and promoting of merchandise on to shoppers away from a fixed retail location. Second, all channel institutional members are a part of many channel transactions at any given point in time. As a outcome, the complexity of all transactions may be quite overwhelming. Consider what number of totally different products you buy in a single 12 months and the huge number of channel mechanisms you use. https://www.reviewengin.com/6-tips-on-strategic-instagram-marketing/

    BalasHapus
  6. Whether you're looking for the size of the organic market, organic industry trends or insights into the organic consumer, we’re here to help. As the membership-based business association for organic agriculture and products in North America, we are the leading voice for the organic trade in the United States, representing over 9,500 organic businesses across 50 states. We also act fast to correct misinformation in the media, and to proactively promote the inspiring work of Organic Trade Association members. We bring the U.S. organic industry to developing markets around the world through our U.S. Whether you're looking for the size of the organic market, organic industry trends or insights into the organic consumer, we are here to help. We represent our members to government on sector needs, market development and promotion, and strong organic standards and regulations.

    System access and trade placement and execution may be delayed or fail due to market volatility and volume, quote delays, system and software errors, Internet traffic, outages and other factors. At the core of USDA's mission is fostering economic opportunity and innovation that will continue to help American agriculture grow and thrive in a global economy.

    The two NBA people also liked the idea of Garland and Okoro in the backcourt. In terms of players with respectable trade value, Altman has four in Sexton, Garland, Okoro and Allen. A publication intended for participants in an industry or related group of industries.Rumors about layoffs are all over the trades. The business given to a commercial establishment by its customers.Even before noon there was considerable trade.

    Apart from traditional self-sufficiency, trading became a principal facility of prehistoric people, who bartered what they had for goods and services from each other. Historically, openness to free trade substantially increased in some areas from 1815 to the outbreak of World War I in 1914. Trade openness increased again during the 1920s, but collapsed during the Great Depression of the 1930s. Economists and economic historians contend that current levels of trade openness are the highest they have ever been. https://www.reviewengin.com/trade-command-center-review/

    BalasHapus