Total Tayangan Halaman

Pengikut

Jumat, 04 Maret 2011

C++ Language ( English Version)

Back with the Science and Technology blog ...... this time I will introduce to you about C ++ Programming Language ....do u .'ve ever heard? or ever used?
For those who didn;t know ...

C + + is a computer programming language C + + was developed at Bell Labs (Bjarne Stroustrup) in the early 1970s, the language is derived from the language previously, namely BCL, At first, the language is designed as a programming language that run on Unix systems, the development, version ANSI (American National Standards Institute) C programming language became the dominant version, though the version is now rarely used in the development of systems and networks as well as for embedded systems. There's a difference between the C language with C + +, even though those languages use the same syntax, but they have differences, C is a procedural programming languages, where the settlement of a problem is done by dividing the problem into a su-subproblems smaller addition, C + + is a programming language that has the properties of Object-oriented programming, to solve the problem, C + + to do the first step by describing the classes that are child classes previously created as an abstraction from objects of physical, Class contains the object's state, its members and the ability from objectnya, After a few classes created and then solved the problem with Class.C + + is an intermediate-level language,

It said this language is the medium between high-and low-level language. High-level language is a language that is more "manusawi", because the command - the command of this language is more oriented to human language. Visual Basic (VB) and Pascal are two of several examples of high-level language. While low-level language is a language that is more oriented to machine language so that language is not very "humane" J. Examples of low-level language is Assembly.
Well ..... now we go into the making of the program. Some parts that need to be noticed is the header and function. Header is diana we enter the existing library in C + + code into our program. The function is "the place" where we can "experiment" J. It poses all the statements that we make. The simplest program ever known to mankind (very scary words) are:




# Include <iostream>
using namespace std;

void main () {

      
court <<"Hello, World! \ n";
}

In the first line, as we see, there is a command # include <iostream>. The '#' is a preprocessor directive. Preprocessor directive is a command - the command given to the compiler to perform the definition, enter the library files, etc.. Example - an example of this preprocessor are:
· # Define maximum_number 100 000
· # Include "fileku.h"
· # Ifdef maximum_number
# Undef maximum_number
# Define maximum_number_2 1000
# Endif

That means that we insert (include) library iostream into our program code. iostream header that is required for "activities" input and output of the program. Int command itself is because we include iostream into our program code and also using namespace std; where there is a court member in it.
Here are some of the headers contained in the C + +:

· Ctime = time header
· Cstdio = header for C commands such as printf and scanf
· Cmath = header for mathematical operations like sin, cos, sqrt, and tan

· Cstring = header to manipulate the string like strcpy, strcat, etc.


(For more details, see http://cplusplus.com/tutorial)

main () is the main function (main) that must exist in each program C + + we. Used here is to play without a return value and without parameters.

Command by using a backslash ('\') also there are several types, including:
· '\ A' = to generate a sound alert

· '\ T' = tabulation
· '\ 0' = null terminated in the array

The '{' should also be present in every function of C + +, it marks the beginning of the function / program and '}' marks the end of the function / program.

 
Now writing using the language C + +,
Writing in C + + is case sensitive. Which means, C + + distinguish between small and capital letters. Which means (again): variabel_pertama not equal to or mboknya_echi variabel_Pertama not the same as mboknya_Echi J.

Comments in C + + written with '/ /' to comment with a length of one line or '/ *' and '* /' to comment more than one line, where the sign of / * is a "welcome" comment and * / is a "cover" comment. Comments are  written by programmers for a reminder or explanation when reading a code. Words - words in a comment will not be executed by the compiler.

Some mistakes in writing in C + + is:

· Int int; / * one because the name of a variable should not be the same as seuah data type (int) * /
· Int Jam_9; / / false because the variable name starts with a capital letter

· Int 90jam; / * nah, this is also wrong because the name of a variable can not start with numbers * /

Writing is true in C + + is:
· Int Myint; / / true
· Char kata_2; / / true as well ...
· Double bilangan_KeDuA; / * although identifiernya weird name, but this is also true:) * /


Every statement in C + + must be marked ';' at the end of the statement. Examples of writing a true statement in C + + is:

int a, b, c;
a = 1;
b = 2;
c = a + b;

While writing the wrong is:
int a, b, c
because it is considered an error by the compiler, because it is an incomplete statement.
Then the data type .....
Type - type of data known in C + + are as follows:


int
int is an integer data type (integer). Examples of the use of type int is:


int a = 1;
int num1 = 2, num2 = 4;
Note that the value - the value entered in the assign (enter) into a variable - a variable of type int is a number - the number / integer. As the name suggests, can only be int and not worth round fractions (decimal). What if the type is int then the inclusion is the result of the division that is not round results? Then:
int hasil_bagi_bulat = 5 / 2;

The result:
2

This is because 5 divided by 2 = 2.5 then because hasil_bagi_bulat are integers (whole numbers) 2.5 and then rounded to 2.
For decimal numbers alone there are specific types for these numbers.


double
is a special type for numbers which are not rounded aka decimal / fraction. Examples of its use are:
double mydouble = 5:00;
double pecahan_pertama = 2.5, pecahan_kedua = 9.9;

char
is a character data type that can store ranging from: a - z, A - Z, '!', '@', etc.. ± together with its consumer type - the type before:
char letter = 'c';
inisial1 char = 'A', inisial2 = 'W';

char symbol = '#';

bool
are the type who just "hold" value "true" and "wrong" that is, true and false (boolean). Example:
benar_atau_salah bool = true;

string
is a special type to accommodate all the input from the user / character combination is very long. For example:
string_gue string = "nah, kyk gini deh example string ...";


 Well that's the language of C + +, may help ....













Tidak ada komentar:

Posting Komentar