9781423902096_PPT_ch02 - C+ Programming: From Problem...

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

View Full Document Right Arrow Icon
C++ Programming: From Problem Analysis to Program Design, Fourth Edition Chapter 2: Basic Elements of C++
Background image of page 1

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

View Full DocumentRight Arrow Icon
C++ Programming: From Problem Analysis to Program Design, Fourth Edition 2 Objectives In this chapter, you will: Become familiar with the basic components of a C++ program, including functions, special symbols, and identifiers Explore simple data types Discover how to use arithmetic operators Examine how a program evaluates arithmetic expressions
Background image of page 2
C++ Programming: From Problem Analysis to Program Design, Fourth Edition 3 Objectives (continued) Learn what an assignment statement is and what it does Become familiar with the string data type Discover how to input data into memory using input statements Become familiar with the use of increment and decrement operators Examine ways to output results using output statements
Background image of page 3

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

View Full DocumentRight Arrow Icon
C++ Programming: From Problem Analysis to Program Design, Fourth Edition 4 Objectives (continued) Learn how to use preprocessor directives and why they are necessary Explore how to properly structure a program, including using comments to document a program Learn how to write a C++ program
Background image of page 4
C++ Programming: From Problem Analysis to Program Design, Fourth Edition 5 The Basics of a C++ Program Function : collection of statements; when executed, accomplishes something May be predefined or standard Syntax : rules that specify which statements (instructions) are legal Programming language : a set of rules, symbols, and special words Semantic rule : meaning of the instruction
Background image of page 5

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

View Full DocumentRight Arrow Icon
C++ Programming: From Problem Analysis to Program Design, Fourth Edition 6 Comments Comments are for the reader, not the compiler Two types: Single line // This is a C++ program. It prints the sentence: // Welcome to C++ Programming. Multiple line /* You can include comments that can occupy several lines. */
Background image of page 6
C++ Programming: From Problem Analysis to Program Design, Fourth Edition 7 Special Symbols Special symbols + - * / . ; ? , <= != == >=
Background image of page 7

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

View Full DocumentRight Arrow Icon
C++ Programming: From Problem Analysis to Program Design, Fourth Edition 8 Reserved Words (Keywords) Reserved words, keywords, or word symbols Include: int float double char const void return
Background image of page 8
C++ Programming: From Problem Analysis to Program Design, Fourth Edition 9 Identifiers Consist of letters, digits, and the underscore character (_) Must begin with a letter or underscore C++ is case sensitive NUMBER is not the same as number Two predefined identifiers are cout and cin Unlike reserved words, predefined identifiers may be redefined, but it is not a good idea
Background image of page 9

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

View Full DocumentRight Arrow Icon
C++ Programming: From Problem Analysis to Program Design, Fourth Edition 10 Identifiers (continued) The following are legal identifiers in C++: first conversion payRate
Background image of page 10
C++ Programming: From Problem Analysis to Program Design, Fourth Edition 11 Whitespaces Every C++ program contains whitespaces Include blanks, tabs, and newline characters
Background image of page 11

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

View Full DocumentRight Arrow Icon
Image of page 12
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/23/2011 for the course CHEMICAL E 2 taught by Professor Hibasaadeh during the Spring '11 term at University of Jordan.

Page1 / 78

9781423902096_PPT_ch02 - C+ Programming: From Problem...

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

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