CJCoding With Joseph
15per day
← 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