Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 17/4/1435 h Monday Lecture 3 The Parts of a C++ Program.

Similar presentations


Presentation on theme: "1 17/4/1435 h Monday Lecture 3 The Parts of a C++ Program."— Presentation transcript:

1 1 17/4/1435 h Monday Lecture 3 The Parts of a C++ Program

2 2. Q: Mention parts of c++ program 1. Special characters 2. cout > objects 3. endl manipulator 4. \n escape sequence #include directive(not part of c++ program)

3 3 1. Special Characters (العلامات الخاصة) Q: Given the following table fill in the spaces CharacterNameMeaning // Double slashBeginning of a comment # Pound signBeginning of preprocessor directive Open/close bracketsEnclose filename in #include ( ) Open/close parentheses Used when naming a function { } Open/close braceEncloses a group of statements " Open/close quotation marks Encloses string of characters ; SemicolonEnd of a programming statement

4 4 2. The cout > object) cout<< 1. Displays output on the computer screen(شاشة) 2. You use operator << to send output to cout: Ex: 3. can be used to send more than one item to cout: cout << "Programming is fun!”; cout << "Hello " << "there!"; or cout << "Hello "; cout << "there!";

5 5 3. The endl Manipulator You can use the endl manipulator (معالج) to start a new line of output. You can use the endl manipulator (معالج) to start a new line of output. This will produce two lines of output: This will produce two lines of output: Programming is fun cout << "Programming is" << endl; cout << "fun!";

6 6 - This produces(ينتج عنه) one line of output: This produces(ينتج عنه) one line of output: cout << "Programming is "; cout << "fun!“ Programming is fun! Note: We use cin>> for input instead of cout<< For output

7 7 4.The \n Escape Sequence You can also use the \n escape sequence to start a new line of output. This will produce two lines of output: cout << "Programming is\n"; cout << "fun!";

8 8 5. The #include Directive 1. Inserts(تدرج) the contents(محتويات) of another file into the program 2. This is a preprocessor directive, not part of C++ language 3. #include lines not seen by compiler 4. Do not place a semicolon at end of #include line

9 9 - Q: Mention the function of endl to start a new line of output. Q: Mention the function of \n to start a new line of output. Q: Mention the function of #include Inserts(تدرج) the contents(محتويات) of another file into the program Mention the function of cout<< Displays output on the computer screen(شاشة) Mention the function of cin>> Mention the function of cin>> Insert inputs on computer screen

10 10 NO The Parts of a C++ Program // sample C++ program #include #include using namespace std; int main() { cout << "Hello, there!"; return 0; } preprocessor directive Comment(تعليق) which namespace to use beginning of function named main beginning of block for main output statement end of block for main string literal send 0 to operating system


Download ppt "1 17/4/1435 h Monday Lecture 3 The Parts of a C++ Program."

Similar presentations


Ads by Google