tailieunhanh - Lecture Programming in C++ - Chapter 2: Getting started

The main contents of this chapter include all of the following: Basic program structure, C++ syntax, creating a banner, sonnecting strings, character escape sequences, debugging, run-time errors, logic errors. | Chapter 2 – Getting Started Basic Program Structure #include using namespace std; int main( ) { cout using namespace std; int main( ) { cout . . . Creating New Lines in Output Programmer must specify new line Line feeding \n in string constant cout << “\nwe can jump\n\ntwo lines.”; Lesson endl manipulator cout << endl<<“we can jump “; cout << endl<< endl <<“two lines.”; we can jump two lines. Connecting Strings Can use backslash at end of line to indicate string constant to continue with next line Lesson cout << “This will \ continue on same line.” ; cout << “This will continue on same line.”; is equivalent to Character Escape Sequences Other escape sequences exist for formatting Full listing in Table Examples: \t horizontal tab \v vertical tab \% displays percent character \” displays double quote Lesson Debugging Error in program called bug Process of looking for and correcting bugs Three types of errors Syntax Run-time Logic Lesson Syntax Errors Mistakes by violating .

TỪ KHÓA LIÊN QUAN