Outline. Copyright 2012 Pearson. Education, Inc

Objectives 1. Arrays 2. Problem Solving Applied: Hurricane Categories 3. Statistical Measurements 4. Problem Solving Applied: Speech Signal Analysis 5...
Author: Cleopatra Berry
3 downloads 1 Views 1MB Size
Objectives 1. Arrays 2. Problem Solving Applied: Hurricane Categories 3. Statistical Measurements 4. Problem Solving Applied: Speech Signal Analysis 5. Sorting and Search Algorithms 6. Problem Solving Applied: Tsunami Warning Systems 7. Character Strings 8. The string class 9. The vector class 10. Problem Solving Applied: Calculating Probabilities

Copyright © 2012 Pearson Education, Inc.

Outline

Objectives • One-dimensional arrays and vectors • Programmer-defined modules for statistical analysis of data • Functions that sort data and search data • Functions that calculate the probability of an event • Character strings and string objects • Functions defined in the header files cstring and string • Custom header files

Copyright © 2012 Pearson Education, Inc.

Develop problem solutions in C++ containing:

Copyright © 2012 Pearson Education, Inc.

Arrays

• An array is a data structure for storing a contiguous block of data. • All data elements in an array must be of the same type. • Individual elements of the array are specified using the array name and an offset. • In C++ the offset of the first element is always 0 (zero).

Copyright © 2012 Pearson Education, Inc.

Arrays Defined

Syntax: data_type identifier[ [array_size] ] [= initialization_list ]; //array_size must be an integer constant Examples

Copyright © 2012 Pearson Education, Inc.

Array Definition Syntax

int data[5]; //allocates consecutive memory for 5 integer values char vowels[5] = {‘a', ‘e', ‘i', ‘o', ‘u'}; //allocates and initializes double t[100] = {0.0}; //allocates and initialized all values to 0.0

Valid References cout

Suggest Documents