โ Back to Arrays
Question 312
Sum of Absolute Values
Sum of Absolute Values
The array{-4, 3, -2, 5, -1}is given. Add up the absolute value of each element and print the total: 15 That is4 + 3 + 2 + 5 + 1. You may compute an absolute value with a conditional instead of a library call.
Expected Output:
15
Topics:
Arrays
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท Ctrl+Space to expand shortcuts (p, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.