This one appears in my exam, i was partly wrong and I don't know why. Please check. C++ language. Consider the following declarations: const int SIZE = 12; int list[SIZE]; int *listPtr = list; int j = 0; int sum = 0; Which of the following correctly finds the sum of all the elements of list? i) for (j = SIZE - 1; j >= 0; --j) sum += list[j]; ii) sum = listPtr[0]; for (j = 1; j < SIZE; j ++) sum += listPtr[j]; iii) for (listPtr = list; listPtr != list + Size; sum += *(listPtr++)); I chose i and ii, which is partly wrong (got 3/5 points). thank you in advance.

At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Get our expert's

answer on brainly

SEE EXPERT ANSWER

Get your free account and access expert answers to this and thousands of other questions.

A community for students.

This one appears in my exam, i was partly wrong and I don't know why. Please check. C++ language. Consider the following declarations: const int SIZE = 12; int list[SIZE]; int *listPtr = list; int j = 0; int sum = 0; Which of the following correctly finds the sum of all the elements of list? i) for (j = SIZE - 1; j >= 0; --j) sum += list[j]; ii) sum = listPtr[0]; for (j = 1; j < SIZE; j ++) sum += listPtr[j]; iii) for (listPtr = list; listPtr != list + Size; sum += *(listPtr++)); I chose i and ii, which is partly wrong (got 3/5 points). thank you in advance.

Computer Science
See more answers at brainly.com
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Get this expert

answer on brainly

SEE EXPERT ANSWER

Get your free account and access expert answers to this and thousands of other questions

Assuming that `Size` in the third option should be `SIZE`, all three methods seem correct to me (also tested it with a small C program and all three methods give the same result).
thank you, sry couldn't reply to you sooner. my openstudy just doesn't load lately.

Not the answer you are looking for?

Search for more explanations.

Ask your own question

Other answers:

Not the answer you are looking for?

Search for more explanations.

Ask your own question