Xem mẫu
Chapter 2 – Getting Started
Basic Program Structure
#include Header
using namespace std; Location of header files int main( ) Primary function
{ Marks beginning of function body
object cout <<
}
“This is C++!”;string – characters within insertion operator used to print to screenator
Lesson 2.1
C++ Syntax
Rules for writing statements
Semicolon serve as statement terminator Case sensitivity
Blank spaces Spacing
Accepted modifications
Lesson 2.1
Comments
Notes in program describing what code does Perform no action in program
Single line comment structure
– Begin with two slashes (no space between) // – Line by itself or following statement
Multiline comment structure
– Uses delimiters /* comments */
starts comment ends comment
Lesson 2.2
Creating a Banner
Set of comments at beginning of program
– name
– parameters used – history
– author – purpose
– date of program
//*********************** // Name: Sally Student
// Purpose: Assignment 2 // Date: 11/22/2003
// Reference: Chapter 2, #3 //***********************
#include
.
Lesson 2.2
...
- tailieumienphi.vn
nguon tai.lieu . vn