// This program compares the values in 2 arrays #include #include using namespace std; int main() { // NEW topic: Comparing arrays // NOT allowed to: print, assign, compare arrays without loop // try 1: prints for each loc whether values are equal or not int arr1[10]={12, 15, 17}; int arr2[10]={12, 15, 18}; for (int i=0; i<3; i++) if (arr1[i]==arr2[i]) cout << "location " << i << " is equal" << endl; else cout << "location " << i << " is NOT equal" << endl; // we did tries 2-4 in class, and found a problem with each one (see your notes) // goal: print whether arr1 array is identical to arr2 array // try 5 (successful) bool equal=true; for (int i=0; i<3; i++) if (arr1[i]!=arr2[i]) equal = false; cout << endl; if (equal) cout << "arrays are equal. " << endl; else cout << "arrays are NOT equal. " << endl; return 0; }