CJCoding With Joseph
15free / daySign inCreate account
โ† Back to Question List
C++ Code Walkthrough #14

Array Sum with For Loop

easyArrays

๐Ÿ“„ Code

Read carefully โ€” what does this print?
1#include <iostream>
2using namespace std;
3 
4int main() {
5 int arr[] = {3, 1, 4, 1, 5};
6 int sum = 0;
7 for (int i = 0; i < 5; i++) {
8 sum += arr[i];
9 }
10 cout << sum << endl;
11 return 0;
12}

๐ŸŽฏ Your Answer