INTRODUCTION C + +
Talking about C and C + + as the language of its predecessor, C an n pemrograma including mid-level language. Creator of C was Brian W. Kernighan and Dennis M. Ritchie in 1972. C is a programming language structured program divides into a number of blocks (sub-program). The aim is to facilitate the making and program development. Programs written with C easily moved from one type of machine to another. it is because of the standardization of C is ANSI (American National Standards Institute) the reference compiler makers C.
C + + was created a decade after C. C + + was created by Bjarne Stroustroup from Bell Laboratories, AT & T in 1983. At first C + + is named "A better C". Name of C + + itself named by Rick Mascitti. The + sign + derived from the increment operator in C language.
C is a privilege because this language supports OOP (Object Oriented Programming). The main goal is to improve the manufacturing C productivity of programmers in creating applications. Most experts agree that OOP and C can reduce the complexity of the program, especially comprises more than 10,000 lines, it can even increase productivity 2X of C, Pascal and Basic.
B. Object Oriented Programming (OOP)
OOP basic idea is to combine data and functions to access the data into a unified unit. This unit is known as an object. as an illustration for mempurmudah understand it, the object may actually reflect patterns of everyday human labor. An object can be described as departments within a business firm, for example, the department.
-sale
-accounting
-personnel
Division of the department in the company is an attempt to facilitate operation of the company. As an illustration, if you are a manager sales in the central office wants to know the data of the salesmen at the branch office,what do you do? Steps you traveled certainly not come to branches and look for these data. To ease your task Your pretty secretary told to ask for information. The issue of how and who find not your business. Analogy with it, if someone intends to use the object, it simply send a message to the object and the object itself is going to handle it.
C. program C
C programs can be created using any text editor or editor as well as the compiler. The main program extension (. CPP). At the time of compilation The main program along with the header files (. h) will be translated by compiler into an object file (. OBJ). Furthermore this object files together with other object files and library files (. LIB) linked together by a linker. The result is a file (. EXE) executable.
D. Compiler C + +
C + + compiler that has been circulating in the market such as Microsoft C / C + + and Visual C + +. Both are from Microsoft. While international Borland also issued Turbo C + + and Borland C + +.
RECOGNITION PROGRAM C + +
A. Hello World
Here is an example C + + program that is simple
# include
void main ()
{
cout << "Hello world. \ n";
}
Once compiled and Dirun, the result is Hello World appears on the screen.
B. Function main ()
Program C + + is not be separated from a function / function. it is as is characteristic of OOP. A C + + program has at least one function the main (). This function is the beginning of the main program. Writing main () is the name of the function, while the parts are enclosed with {and} are called block (body function). In this case an early sign {} block and is marks the end of the block. As in Pascal, the Pascal {identical with BEGIN, while synonymous with} END. Command void means that the function main () does not return a value / value.
Way of writing the function main () is not absolute as above. Here's how another writing
# include
int main ()
{
cout << "Hello world. \ n";
return 0;
}
C. Statement
Command cout << "Hello world. \ n "; was one example statement. The command is used to print text on the screen. Each statement must end with;
It is important to note here that the C + + program is Case Sensitive, meaning uppercase and lowercase letters are considered different.
The \ n is used to move the line.
D. file Header
In the example above , called iostream.h header file . The header file necessary for court orders can be executed . If the header file removed , then the error will occur . To access the header file , use command # include
Note :
Command cout << " Hello world . \ N " ; can be replaced with printf ( " Hello world . \ n " ) ;
But to be able to use printf required header file stdio.h
E. Removing Screen
In C + + , the command clrscr ( ), is used to remove / clean up the screen . This command will be run after adding the header file conio.h
# include
# include
void main ( )
{
clrscr ( ) ;
cout << " Hello world . \ n " ;
}
F. comment
You can add comments to your program . The following style for add comments .
/ / ----------------------------------
/ / This is the first remarked
/ / ----------------------------------
or
/ * ----------------------------------
I remarked that this was the first
---------------------------------- * /
Thank you for reading the article BASIC PROGRAMMING C + + is hopefully a little useful for the reader as well.
Regards .. andregk.blogspot.com :)
Tidak ada komentar:
Posting Komentar