#include <iostream>
using namespace std;
int main() {
long int s = 0;
int N;
cin >> N;
for (int i = 1; i <= N; i++) {
s += i * i;
cout << i * i << " ";
}
cout << endl << s;
return 0;
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
#include <iostream>
using namespace std;
int main() {
long int s = 0;
int N;
cin >> N;
for (int i = 1; i <= N; i++) {
s += i * i;
cout << i * i << " ";
}
cout << endl << s;
return 0;
}