13-Arrays-4up

# Int price4 price0 10 price4 11 price 1

This preview shows page 1. Sign up to view the full content.

This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 3 The array name, without the , gives the address of the start of the array. 8 Comparing arrays Review ì const int SIZE = 3; int first = {1, 2, 3}, second = {1, 2, 3}; bool areSame = true; for (int i=0; i<SIZE; i++) { for each i check if if (first[i] != second[i]) { areSame = false; first[i] == second[i]] } } if (areSame) { cout << "Contents of arrays are the same!"; } Variables: Array Objects: int first 0 1 1 2 1 2 float b=0; float element={10.1, 2.5, 5,7} for (int i=0;i<3;i++){ b=b+element[i]; } cout << b; 2 3 int second Create an array holding the values 10.1, 2.5 and 5.7; Write a loop to sum up all elements in the array; Outp...
View Full Document

## This note was uploaded on 10/09/2012 for the course CMPT 125 taught by Professor Diana during the Spring '08 term at Simon Fraser.

Ask a homework question - tutors are online