13-Arrays-4up

Int price4 price0 10 price4 11 price 1

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

View Full Document Right Arrow Icon
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

Ask a homework question - tutors are online