《C++程序设计》(英文版) Chapter 2 Topics

Programming in c++ C++ Syntax and Semantics and the Program Development Process Dale/eems/Headington
1 C++ Syntax and Semantics, and the Program Development Process

Programming in C++ Chapter 2 Topics Syntax and Semantics s Programs Composed of Several Functions Syntax Templates s Legal C++ Identifiers x Data and Data Types Assigning values to Variables s Declaring Named Constants s String Concatenation Output Statements C++ Program Comments
2 Chapter 2 Topics ❖Syntax and Semantics ❖Programs Composed of Several Functions ❖Syntax Templates ❖Legal C++ Identifiers ❖Data and Data Types ❖Assigning Values to Variables ❖Declaring Named Constants ❖String Concatenation ❖Output Statements ❖C++ Program Comments

Programming in C++ Syntax and Semantics a programming language is a set of rules, and special words used to construct a program. There are rules for both syntax (grammar) and semantics(meaning) Syntax The formal rules governing how valid instructions are written in a programming language Semantics The set of rules that determines the meaning of Instructions written in a programming language
3 Syntax and Semantics ❖A programming language is a set of rules,and special words used to construct a program.There are rules for both syntax (grammar) and semantics (meaning). ❖Syntax The formal rules governing how valid instructions are written in a programming language. ❖Semantics The set of rules that determines the meaning of instructions written in a programming language

Programming in C++ Syntax Templates Let's look at the syntax template for the C++ main function Main Function int main o Statement
4 Syntax Templates Let’s look at the syntax template for the C++ main function. Main Function int main () { Statement . . . }

Programming in C++ A C++ program is a collection of one or more functions o there must be a function called main() % execution always begins with the first statement in function main() o any other functions in your program are subprograms and are not executed until they are called
5 A C++ program is a collection of one or more functions ❖there must be a function called main( ) ❖execution always begins with the first statement in function main( ) ❖any other functions in your program are subprograms and are not executed until they are called

Programming in C+ Program With Several Functions main function square function cube function
6 Program With Several Functions main function square function cube function

Programming in C+ Program With Three Functions include int Square( int )i / declares these two int Cube( int )i // value-returning functions using namespace std int main() cout < wThe square of 27 is w < Square(27)<< endl y£ unction ca11 cout < uThe cube of 2 is 1 < Cube(27)<< endl / function call return 0 7
7 Program With Three Functions #include int Square( int ); // declares these two int Cube( int ); // value-returning functions using namespace std ; int main( ) { cout << “The square of 27 is “ << Square(27) << endl; // function call cout << “The cube of 27 is “ << Cube(27) << endl; // function call return 0; }

Programming in C++ Rest of Program int Square( int n) return n"n; int Cube( int n return n*n*n
8 Rest of Program int Square( int n ) { return n * n; } int Cube( int n ) { return n * n * n; }

Programming in C++ Output of program The square of 27 is 729 The cube of 27 is 19683
9 Output of program The square of 27 is 729 The cube of 27 is 19683

Programming in C+ Every C++ function has 2 parts int main() heading body block return o
Every C++ function has 2 parts int main ( ) heading { body block return 0; }
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
- 《C++程序设计》(英文版) Chapter 1 Topics.ppt
- 《网络互连技术教程》第9章 广播.ppt
- 《网络互连技术教程》第8章 用户数据报协议—UDP.ppt
- 《网络互连技术教程》第7章 CMP和网络状态.ppt
- 《网络互连技术教程》第6章 地址解析.ppt
- 《网络互连技术教程》第5章 子网与超网.ppt
- 《网络互连技术教程》第4章 网络互连协议——IP.ppt
- 《网络互连技术教程》第3章 网络接入技术.ppt
- 《网络互连技术教程》第2章 网络互连体系.ppt
- 《网络互连技术教程》第1章 网络的历史与发展.ppt
- 《网络互连技术教程》第12章 应用服务.ppt
- 《网络互连技术教程》第11章 域名服务系统—DNS.ppt
- 《网络互连技术教程》第10章 传输控制协议—7CP.ppt
- 高职高专课程:《数据库应用技术(SQL SERVER2000)》电子教案(PPT教学课件)第9章 存储过程与触发器.ppt
- 高职高专课程:《数据库应用技术(SQL SERVER2000)》电子教案(PPT教学课件)第8章 视图及其应用.ppt
- 高职高专课程:《数据库应用技术(SQL SERVER2000)》电子教案(PPT教学课件)第7章 索引及其应用.ppt
- 高职高专课程:《数据库应用技术(SQL SERVER2000)》电子教案(PPT教学课件)第6章 SQL Server 2000 数据完整性.ppt
- 高职高专课程:《数据库应用技术(SQL SERVER2000)》电子教案(PPT教学课件)第5章 数据的基本操作.ppt
- 高职高专课程:《数据库应用技术(SQL SERVER2000)》电子教案(PPT教学课件)第4章 数据库中表的基本操作.ppt
- 高职高专课程:《数据库应用技术(SQL SERVER2000)》电子教案(PPT教学课件)第3章 数据库的基本操作.ppt
- 《C++程序设计》(英文版) Chapter 3 Topics.ppt
- 《C++程序设计》(英文版) Chapter 4 Topics.ppt
- 《C++程序设计》(英文版) Chapter 5 Topics.ppt
- 《C++程序设计》(英文版) Chapter 6 Topics.ppt
- 《C++程序设计》(英文版) Chapter 7 Topics.ppt
- 《C++程序设计》(英文版) Chapter 8 Topics.ppt
- 《C++程序设计》(英文版) Chapter 9 Topics.ppt
- 《C++程序设计》(英文版) Chapter 10 Topics.ppt
- 《C++程序设计》(英文版) Chapter 11 Topics.ppt
- 《C++程序设计》(英文版) Chapter 12 Topic.ppt
- 《C++程序设计》(英文版) Chapter 13 Topics.ppt
- 《C++程序设计》(英文版) Chapter 14 Topics.ppt
- 《C++程序设计》(英文版) Chapter 15 Topics.ppt
- 《Java编程技术基础》第一章 面向对象原理与实现.ppt
- 《Java编程技术基础》第二章 Java的实现基础.ppt
- 《Java编程技术基础》第二章习题.doc
- 《Java编程技术基础》第三章 类与对象(一).ppt
- 《Java编程技术基础》第三章习题.doc
- 《Java编程技术基础》第四章 类与对象(二).ppt
- 《Java编程技术基础》第四章习题.doc