Skip to main content

Pengenalan Dasar C

Pengenalan Dasar C




Langsung saja  di bawah ini satu program dasar  beserta keterangan-keterangan untuk memudahkan anda memahami program C++. Bukalah editor C++ ( File >New>Text Edit..).kemudian ketikan source code berikut ini..





//program dasar C++
#include <iostream.h>
#include <conio.h>
void main()
{
 char nama;

 cout<<"Mari Belajar C++";
 cout<<"Nama Saya Adalah "; cin>>nama;
 cout<<endl;
 clrscr();
 cout<<nama<<" Belajar C++";
 getch();
}

Compile Program diatas, caranya, tekan Alt + F9 pada keyboard, jika sukses, jalankan programmnya, tekan Ctrl + F9 pada keyboard..


Keterangan beserta Penjelasannya :

1. #include adalah pre prosesor yang tersedia pada C++ dan selalu dijalankan terlebih dulu saat kompilasi..juga tidak di akhiri dengan tanda ( ; ) karena #include bukanlah suatu pernyataan melainkan suatu file header.
contohnya:
- #include digunakan pada program jika program tersebut melibatkan object cout dan cin.
- #include diperlukan apabila melibatkan fungsi clrscr() (baca: clear screen), yaitu perintah untuk membersihkan layar, dan fungsi getch() [baca: get character and echo], untuk menahan layar sampai sembarang tombol keyboard ditekan.
#include , diperlukan jika dalam program terdapat suatu operator matematika ( +, -, : dan x ) atau perhitungan matematika, semisal penjumlahan, pengurangan, perkalian, dsb..

2. void main() adalah suatu fungsi dalam bahasa C++, merupakan fungsi utama dalam program..terdapat banyak fungsi dalam bahasa C++, salah satunya adalah fungsi main(). 
Ada tiga bentuk penulisan fungsi main: void main(), int main()dan b.. Penggunaanya tergantung dari program yang dipakai.. tapi untuk pengenalan dasar, lebih baik menggunakan void main() dulu sampai anda mengenal lebih jauh bahasa C++.. Setiap penulisan fungsi selalu di awali tanda ( { ) dan di akhri tanda [ } ], dimana menunjukan cakupan dari fungsi..

3. cout [dibaca: C out] adalah sebuah objek pernyataan dalam C++ yang digunakan untuk menampilkan atau mencetak data pada layar dan selalu di akhiri tanda [ ; ]. 
Sedangkan cin [dibaca: C in] adalah sebuah objek pernyataan untuk memasukkan atau menginputkan data pada layar..
Ingatlah setiap selesai membuat pernyataan maka harus diakhiri tanda [ ; ]

4.
<< adalah operator penghubung antara stream dan kalimat,,ditujukan pada cout karena kita akan mencetak kalimat ke layar..
 Sedangkan >> adalah operator yang ditujukan pada data karena kita akan menginputkan data ke layar.. Bentuk umum code nya adalah seprti ini..


cout<<"Kalimat yang kita ketik";
cin>>data;

5. // adalah operator komentar. Operator ini tidak akan diproses atau di compile oleh compiler..karena hanya berfungsi sebagai komentar..

6. endl [baca: end line] adalah fungsi yang digunakan untuk pindah baris atau baris baru..

7. char adalah sebuah tipe data yang digunakan untuk memasukkan huruf. pada program sederhana diatas, data yang dimasukkan adalah nama, jadi kita memakai tipe data char. Terdapat banyak tipe data dalam bahasa C++. Diantaranya:
int - untuk memasukkan data berupa angka
float - untuk memasukkan data berupa angka desimal

Sekian dulu yang dapat saya jelaskan mengenai dasar-dasar program C++..semoga bermanfaat.

download file now

Popular posts from this blog

Lightshot Easy Screen Shot Print Screen terbaru Desember 2016 versi 5 4 0 1

Lightshot Easy Screen Shot Print Screen terbaru Desember 2016 versi 5 4 0 1 Do you want to take screenshots outside of your browser? Choose the most functional Lightshot download option in order to get this opportunity. This application allows you to take screenshots directly from your desktop. Feature : Fast screenshot of selected area - Our app allows you to select any area on your desktop and take its screenshot with 2 button-clicks. Easy-to-use application - Simple interface of our app, its useful features and light weight make your work so very fast and pleasant. Share screenshots via Internet - Upload your screenshot to the server and get its short link right away. Powerful editors - You can edit screenshots instantly when taking them or later using a powerful online editor. Similar image search - Find similar images. Select any image on your screen and find dozens similar images. Various Platforms - Lightshot is available for Windows/Mac, Chrome, Firefox, IE & Opera....

SHERLOCK HOLMES THE HOUND OF BASKERVILLES O CÃO DOS BASKERVILLES DUBLADO 1959

SHERLOCK HOLMES THE HOUND OF BASKERVILLES O CÃO DOS BASKERVILLES DUBLADO 1959 DETALHES T�CNICOS DO ARQUIVO �timo filme cl�ssico com Christopher Lee para download gr�tis. Download do filme legendado, download do torrent e download da legenda em portugu�s. Veja abaixo os dados t�cnicos deste filme. FICHA T�CNICA LINK DIRETO �UDIO: PORTUGU�S LEGENDAS: SEM LEGENDAS FORMATO: AVI - MKV TAMANHO: 461Mb - 990Mb LINKS: PARTE �NICA FICHA T�CNICA BAIXAR TORRENT �UDIO: INGL�S LEGENDAS: COM OU SEM LEGENDAS FORMATO: V�RIOS SINOPSE Um mal demon�aco oculta-se no fundo dos penhascos cobertos pela n�voa dos lend�rios terrenos de ca�a na Inglaterra. Na forma de um diab�lico c�o de ca�a, ele se alimenta da carne dos herdeiros da mans�o Baskerville. Mas antes que essa besta selvagem possa cravar seus dentes no mais novo dono da propriedade, ele precisa lan�ar suas ferozes presas contra o perspicaz intelecto do mais poderoso advers�rio que ele jamais encontrou, o incompar�vel Sherlock Holmes. Mais informa��e...

How to Run Mac OS Sierra on a PC Windows 10 8 or 7 Best Method 2017

How to Run Mac OS Sierra on a PC Windows 10 8 or 7 Best Method 2017 Birsa Agricultural University Recruitment 2017� 85 Scientist, Programme Assistant Graduate Pass Govt Job Birsa Agricultural University is going to recruit fresher candidates in India for Scientist, Programme Assistant Posts. So, those candidates who are willing to work with this organization they May apply for this post. Last Date of Apply 28-August-2017. Total numbers of vacancies are 85Posts. Only those candidates are eligible who have passed Bachelor�s Degree in Agriculture or other branch of science relevant to Agriculture or equivalent/ qualification from a recognized university. Indian citizen having age in between 18 to 35 years can apply for this Birsa Agricultural University Recruitment 2017. Those who are interested in these Birsa Agricultural University jobs in India and meet with the whole eligibility criteria related to these Birsa Agricultural University job below in the same post. Read the whole arti...