Chap2 - Chapter 2 Problem Solving Using C+ 1 Outline...

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

View Full Document Right Arrow Icon
1 Chapter 2 Problem Solving Using 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
2 Outline ± Introduction to C++ ± Programming Style ± Data Types ± Arithmetic Operations ± Variables and Declaration Statements
Background image of page 2
3 ± Modular Program: a program consisting of interrelated segments arranged in a logical and understandable form ± Easier to develop, correct, and modify than other kinds of programs ± Module: a small segment which is designed to perform a specific task ± A group of modules is used to construct a modular program Introduction to C++
Background image of page 3

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

View Full DocumentRight Arrow Icon
4 Introduction to C++ (continued) Figure 2.1 A well-designed program is built using modules.
Background image of page 4
5 Modules in C++ can be classes or functions ± Function: accepts an input and produces an output by processing the input in some fashion ± Class: contains both data and functions used to manipulate the data Introduction to C++ (continued)
Background image of page 5

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

View Full DocumentRight Arrow Icon
6 Introduction to C++ (continued) Figure 2.2 A multiplying function.
Background image of page 6
7 Introduction to C++: The main() Function ± Overall structure of a C++ program contains one function named main() , called the driver function ± All other functions are invoked from main()
Background image of page 7

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

View Full DocumentRight Arrow Icon
8 Introduction to C++: The main() Function (continued) Figure 2.3 The main() function directs all other functions.
Background image of page 8
9 Introduction to C++: The main() Function (continued) Figure 2.4 The structure of a main() function.
Background image of page 9

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

View Full DocumentRight Arrow Icon
10 Introduction to C++ : The main() Function (continued) ± Function header line: the first line of a function, which contains ± The type of data returned by the function (if any) ± The name of the function ± The type of data that must be passed into the function when it is invoked (if any) ± Arguments: the data passed into a function ± Function body: the statements inside a function (enclosed in braces)
Background image of page 10
11 Introduction to C++: The main() Function (continued) ± Each statement inside the function must be terminated with a semicolon ± return : a keyword causing the appropriate value to be returned from the function ± return 0 in the main() function causes the program to end
Background image of page 11

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

View Full DocumentRight Arrow Icon
12 Introduction to C++: The cout Object ± cout object: an output object that sends data to a standard output display device
Background image of page 12
13 Introduction to C++: The cout Object (continued) ± Preprocessor command: starts with a # ; causes an action before the source code is compiled into machine code ± #include <file name> : causes the named file to be inserted into the source code ± C++ provides a standard library with many pre- written classes that can be included ± Header files: files included at the head (top) of a C++ program
Background image of page 13

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

View Full DocumentRight Arrow Icon
14 Introduction to C++ : The cout Object (continued) ± using namespace <namespace name> : indicates where header file is located ± Namespaces qualify a name; a function name in your class can be the same as one used in a standard library class ± String: any combination of letters, numbers, and special characters enclosed in double quotes (a delimiter) ± Delimiter: a symbol that marks the beginning and ending of a string; not part of the string
Background image of page 14
15 Introduction to C++ : The cout Object (continued)
Background image of page 15

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

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

This note was uploaded on 03/09/2009 for the course CSC 101 taught by Professor Betancourt during the Spring '09 term at CUNY City.

Page1 / 96

Chap2 - Chapter 2 Problem Solving Using C+ 1 Outline...

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

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