arrays

arrays - Preliminaries Arrays C+ Arrays Len Blanks CSC 1253...

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

View Full Document Right Arrow Icon
Preliminaries Arrays C ++ Arrays Len Blanks CSC 1253 Introduction To Computer Science I Using C ++ Louisiana State University October 15, 2010 Len Blanks C ++ Arrays
Background image of page 1

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

View Full DocumentRight Arrow Icon
Preliminaries Arrays Topics 1 Preliminaries 2 Arrays Len Blanks C ++ Arrays
Background image of page 2
Preliminaries Arrays References The material for this lecture is heavily based on content from The C ++ Programming Language by Bjarne Stroustrup. Big C ++ by Cay Horstmann and Timothy Budd. Len Blanks C ++ Arrays
Background image of page 3

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

View Full DocumentRight Arrow Icon
Preliminaries Arrays Array Declarations Format: type name array variable [ size ] Example: double scores[10]; size must be specified at compile time and cannot be changed. As with non-array variables, an optional initialiser may be used: double scores[] = {45.75, 98.5, 87.0, 72.0, 100.0, 65.25, 78.0, 83.0, 95.25, 53.0}; There is no need to specify the size if an initialiser is used; the compiler will simple count the values. Len Blanks C ++ Arrays
Background image of page 4
Preliminaries Arrays Array Parameters When writing a function with an array parameter, an empty [] is placed after the array name: double max_value(double a[], int size) Unlike all other parameters, array parameters are always passed by reference. Although arrays are allowed as function parameters, they may never be function return types. Len Blanks C ++ Arrays
Background image of page 5

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

View Full DocumentRight Arrow Icon
Preliminaries Arrays Examples #include <iostream> #include <iomanip> #include <fstream> #include <cstdlib> using namespace std; Len Blanks C ++ Arrays
Background image of page 6
Preliminaries Arrays Examples int maxIndex(double arr[], int size) { /** * determines and returns the index to the largest value * in an array * @param
Background image of page 7

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

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

This note was uploaded on 10/02/2011 for the course CSC 1253 taught by Professor Staff during the Fall '08 term at LSU.

Page1 / 20

arrays - Preliminaries Arrays C+ Arrays Len Blanks CSC 1253...

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

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