- # include
. The sentence that begins with the sign (#) is a directive to preprosesor. Not a line of code is executed, but the indications for the compiler. In this case the phrase # include notify preprosesor header compiler to include the iostream standard file. This specific file also includes declarations standard library I / O in C + + and this file is included because its functions will be used later in the program. The function used is the court stands for the console out or display data to the console or screen. - # include
Because using getch, it is necessary declaration header file that stores declaration conio getch function.
- int main ()
This line matches at the beginning of the declaration of main functions. main function is the starting point where all the C + + program will begin execution. Placed at the beginning, middle or end of the program, the contents of the main functions will always be executed first. Basically, the entire C + + programs have a main function. play followed by a pair of parentheses () as a function. in C + +, all functions followed by a pair of parentheses () where, can contain arguments therein. The contents of the main function will then be followed, a formal and written declaration of ({}), brace as in the example. - court << "Hello World";
This instruction is the most important thing in the program examples. court is the standard output stream in C + + (usually the monitor). court declared in the header file iostream.h, so in order to use the file must be included. Consider every sentence ends with a semicolon (;). This character marks the end of the instruction and must be included at the end of each instruction in C + + programs of any. - getch ();
The function getch () function is to receive from the user entered via the keyboard, but in this program, getch only serves to stop the process before the results window disappears. If the getch command does not exist, then the results window will appear briefly and then quickly disappeared, so the last command executed. - return 0;
Return instruction causes the function main () ends and returns the code that follows these instructions, in this case 0. This is the most often used to terminate the program. Not all lines in this program take action. There are lines containing only comments (preceded / /), a line that contains instructions to the compiler preprocessor (the beginning #), then the row is the initialization of a function (in this case, the main function) and the rows that contain instructions (eg, court < <), the last line is included in the block bounded by curly braces (()) of the main functions - Comments
In row 1, found in alert / * and on line 4 in the sign * /. Both these signs are useful in pairs to write a comment about the program or the commands. Comments do not affect the program because the comments did not run as command (statement). Comments by using signs / * apply to find a * /. Another way to provide comments is to provide a slash 2 times. Comments by this sign only applies to the 1 line. Comments are optional to facilitate the people to know the function of a program or an algorithm - # include
At 6 in the command line # include "stdio.h" and on line 7 is the command # include. Both commands are used to call the header file (include file) in which there command, function or prototype that can be used in programs created. If the command # include is not written, then the computer does not understand the orders written. - Header files
The file name used in # include as conio.h and stdio.h, called the header files because placed at the top of the program. Extention H means header. In this header file, there is a function or a prototype that can be used in the program. A header file has more than 1 function or variable stdio.h header global.File used for handling input / output standards such as writing to the screen, to files or reading data from the keyboard or a file.
Stdio.h header file is used to handling the screen as color settings, the time gap (delay), voice internal.Stillmany other standard header files stdio.h and conio.h. - Function main ()
In line 8 there is declaring the function main (). This function is a special function to be executed first. Each program must have a function main (). Function main () begins with a sign stating (beginning of the program and ends with a) is declared the end of the program. - printf ()
printf () is a function that allows you to write messages to the screen. Messages to be written in the enclosed by quotation marks. Written messages can be adjusted by adjusting the format of the writing. The function printf () not just write a message in just 1 line but can be more. To move the line then use the command \ n which means the new line (new line). Writing \ n may be placed in the front, middle or end. To write the sign "(quotes) then must use the \". Further information will be explained in subsequent chapters. - Signs; (semikolon)
Each command must end with a sign;. Loss of signal; will cause compilation errors. - getch ()
getch () is a function that works for reading data from a character, so the program will pause until the user pressed a button. This function is in the header files so conio.h command # include "conio.h" should be written. If the command getch () is not written, then the program will be done quickly and execution can not be seen. - return
return is the command that gives value to the function. Every function must have the change the value (return value).
Wednesday, November 18, 2009
Fungcion C++
Fungcion C++
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment