Calculate Array Sum
You are provided with a C++ function calculateArraySum that is intended to compute the sum of all integer elements in a given array. The function takes two arguments: an integer array arr and its size n.
Currently, the function contains an error in its loop condition and is missing the accumulation logic.
Your task is to:
- Fix the bug in the loop condition to ensure all elements are processed correctly.
- Complete the logic inside the loop to correctly accumulate the sum.
- Ensure the function returns the correct total sum.
calculate_array_sum.cpp
Loading...
Use the "Verify Solution" button to get AI feedback on your c++ code.