CJCoding With Joseph
← Back to Question List
C++ Code Walkthrough #39

Squaring Array Elements

easyArrays

📄 Code

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

🎯 Your Answer