So I've written this code and it works until I try implemented a part of my second for loop where I try to print a new line. It is suppose to print a new line when it comes across the 8th position in the array. Any help appreciated.
// Construct a for loop that runs backwards through the array,
// starting at the last element and ending at the first.
for (int i = arraySize; i > 0; i--) {
// Inside this for loop, print the ith element of the array
// and a tab, with NO newline characters.
cout << newArray[i-1] << " ";
// If this element is the 8th one on its line, print a
// newline character to advance to the next line.
// Also inside this for loop, add the value of the ith
// element to the current value of the double for the sum
// of elements.
//ISSUE IS HERE
if (newArray[i-8] = newArray[7]) {
cout << "\n";
}
sumOfElements += newArray[i-1];
}
I've only pasted the for loop that has the issue, I don't believe any other information is necessary as I know it works up until this point.
Aucun commentaire:
Enregistrer un commentaire