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