#include <iostream> using namespace std; int main() { // write your code here...... long sum = 0; long a[10] = {9, 99, 999, 9999, 99999, 999999, 9999999, 99999999, 999999999, 9999999999}; for (int i = 0; i < 10; i++) { sum += a[i]; } cout << sum << endl; return 0; }
#include <iostream> using namespace std; int main() { // write your code here...... long sum = 0; long num = 0; for (int i = 1; i <= 10; i++) { num = num * 10 + 9; sum += num; } cout << sum << endl; return 0; }