// get sum from x to y // initialization of variables int x = 1, y = 100, sum = 0; // loop from x to y and add up the current index i for(int i = x; i = y; i++) sum += i; std::cout << sum;