Chap02 - Chapter 2 C+ Syntax and Semantics, and the Program...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Chapter 2 C++ Syntax and Semantics, and the Program Development Process Chapter 2 C++ SYNTAX AND SEMANTICS, AND THE PROGRAM DEVELOPMENT PROCESS CHAPTER GOALS To understand how a C++ program is composed of one or more subprograms (functions). To be able to read syntax templates in order to understand the formal rules governing C++ programs. To be able to create and recognize legal C++ identifiers. To be able to declare named constants and variables of type char a nd string . To be able to distinguish reserved words in C++ from user-defined identifiers. To be able to assign values to variables. To be able to construct simple string expressions made up of constants, variables, and the concatenation operator. To be able to construct a statement that writes to an output stream. To be able to determine what is printed by a given output statement. To be able to use comments to clarify your programs. To be able to construct simple C++ programs. To learn the steps involved in entering and running a program CHAPTER OUTLINE I. The Elements of C++ Programs A. C++ Program Structure B. Syntax and Semantics Theoretical Foundations : Metalanguages C. Syntax Templates D. Naming Program Elements: Identifiers Matters of Style : Using Meaningful, Readable Identifiers E. Data and Data Types Background Information : Data Storage 1. The Char Data Type 2. The String Data Type F. Naming Elements: Declarations 1. Variables 2. Constants Matters of Style : Capitalization of Identifiers G. Taking Action: Executable Statements 1. Assignment 2. String Expressions 3. Output H. Beyond Minimalism: Adding Comments to a Program II. Program Construction A. Blocks (Compound Statements) B. The C++ Preprocessor 13
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Chapter 2 C++ Syntax and Semantics, and the Program Development Process C. An Introduction to Namespaces III. More About Output A. Creating Blank Lines B. Inserting Blanks Within a Line IV. Program Entry, Correction, and Execution A. Entering a Program B. Compiling and Running a Program C. Finishing Up V. Problem-Solving Case Study : Contest Letter VI. Testing and Debugging VII. Summary GENERAL DISCUSSION This chapter introduces many concepts that the students must learn. All of them are important, but some are much easier to learn if the following basics are first thoroughly grasped. The first concept is the overall structure of a C++ program: a collection of one or more functions, one of which must be named main . Students and instructors with Pascal backgrounds may be displeased that C++ refers to all subprograms as functions . Pascal terminology distinguishes between subprograms that return a single value ( functions ) and those that do not ( procedures ). C++'s use of function as an umbrella term may seem to be nonstandard, but there actually is not a universal standard. (For example, Modula-2, in a direction 180 o opposite that of C++, eliminates the reserved word FUNCTION and refers to all subprograms as procedures!) Throughout the book, we follow the C++ convention of using
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 06/13/2011 for the course CSC 140 taught by Professor Lebre during the Spring '04 term at Moraine Valley Community College.

Page1 / 7

Chap02 - Chapter 2 C+ Syntax and Semantics, and the Program...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online