Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "Hello World Using C++ (L03) * Introduction C++ * Programming Style * Hello World Using C++ Hollow World Using C/C++ Dr. Ming Zhang."— Presentation transcript:

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

2 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++. 4. The maximum number of characters in a function name is 31 characters. Hollow World Using C/C++ Dr. Ming Zhang

3 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

4 Keywords for C++ autobreakcasechar constcontinuedefaultdo doubleelseenumextern floatforgotoif intlongregisterreturn shortsignedsizeofstatic structswitchtypedefunion unsignedvoidwhile class Hollow World Using C /C++ Dr. Ming Zhang

5 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

6 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

7 Standard Output Stream- cout * Standard Output Stream cout * Example cout << “Welcome to C++!\n”; instructs the computer to print on the screen the string of characters contained between the quotation marks. Hollow World Using C/C++ Dr. Ming Zhang

8 Hello World Using C++ #include using std::cout; // program uses cout using std:cin; // Program uses cin using std:endl; // program uses endl int main ( ) { cout << “Hello World!” << endl; return 0; // program ended successfully } Hollow World Using C /C++ Dr. Ming Zhang

9 Home Work Using C++ to show your name on the screen. The output of screen much be : My first name is: Ming My last name is: ZHANG Hollow World Using C /C++ Dr. Ming Zhang


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

Similar presentations


Ads by Google