Arrays Syntax: type variableName[size]; Memory Is Set Aside for size Items of type Each Variable Location in Array Is Accessed by Offsetting into the Array with an Integer Expression Legitimate Offsets Are 0 to size-1 Example: lastname[0] = ‘H’;
Array Example int values[15]; values[0] = 150; values[1] = 78; cout << values[0]; values[3] = values[0] + 6;
Initializing Arrays int main() { char cArray3[5] = {'a', 'b', 'c'}; int iArray[] = {1, 2, 3, 4}; int iArray2[10] = {10, 13, 15, 17}; double dArray[] = {3.4, 5.67e4}; double dArray1[5] = {6.7, 7.8, 9.5}; }
Initializing string Arrays #include <string> using namespace std; int main() { string sArray[] = {"one", "two", "three"}; cout << sArray[0]; }
Two Dimensional Arrays char cArray[10][20]; int iArray[100][50]; cArray[0][0] = ‘a’; cArray[0][1] = ‘b’; cArray[9][19] = ‘x’; iArray[0][0] = 99; iArray[1][5] = 135; iArray[99][49] = 0;
Final Exam 2 Hours 200 Points 35% of Grade Must Take to Pass Course
Need to Know for Final Everything Through Exam 2 Terminology Loops Switch/Case Files Functions Arrays
Final Exam 200 Points Total – 35% of Final Grade 60 points Matching or Short Answer or Multiple Choice (Terminology, Operators, C++ Basics) 30 Points Program Output 80 Points Programming (Full Programs) 30 Points Essay