Hello World Using C++ (L03) * Introduction C++ * Programming Style * Hello World Using C++ Hollow...

download Hello World Using C++ (L03) * Introduction C++ * Programming Style * Hello World Using C++ Hollow World Using C/C++ Dr. Ming Zhang.

If you can't read please download the document

description

Examples of Invalid Identifiers * 1AB3: Begins with a number, which violates rule 1. * E*6: Contains a special character, which violates rule 2. * while: while is a keyword reserved for C++, which violates rule 3. Hollow World Using C/C++ Dr. Ming Zhang

Transcript of Hello World Using C++ (L03) * Introduction C++ * Programming Style * Hello World Using C++ Hollow...

Hello World Using C++ (L03) * Introduction C++ * Programming Style * Hello World Using C++ Hollow World Using C/C++ Dr. Ming Zhang Identifiers Identifiers are composed of any combination of letters, digits, and underscore ( _ ) selected according to the following rules: 1. The first character of the name must be a letter or underscore. 2. Only letters, digits, or underscore may follow the initial letter. Blank spaces and other special characters are not allowed. 3. A function name cannot be one of the keyword reserved for C The maximum number of characters in a function name is 31 characters. Hollow World Using C/C++ Dr. Ming Zhang Examples of Invalid Identifiers * 1AB3: Begins with a number, which violates rule 1. * E*6: Contains a special character, which violates rule 2. * while: while is a keyword reserved for C++, which violates rule 3. Hollow World Using C/C++ Dr. Ming Zhang Keywords for C++ autobreakcasechar constcontinuedefaultdo doubleelseenumextern floatforgotoif intlongregisterreturn shortsignedsizeofstatic structswitchtypedefunion unsignedvoidwhile class Hollow World Using C /C++ Dr. Ming Zhang main( ) Function *main( ) function is used to provide for the orderly placement and execution of all other functions. *The reserved word main tells the compiler where program execution is to begin, each C program must have one and only one function called main( ). * The main( ) function is commonly used to invoke other functions by calling them in the sequence in which they are to operate, this function is sometimes referred to as a driver function. Hollow World Using C/C++ Dr. Ming Zhang Structure of main( ) function What type of data, Function What type of data if any, is returned name (argument), if any, from the function. is sent into the function Function header void main (void) { Function Body Program statements in here; } Each statement inside the function must end with a semicolon(;) Hollow World Using C /C++ Dr. Ming Zhang Standard Output Stream- cout * Standard Output Stream cout * Example cout