Answers for "get sum from x to y in c++"

C++
0

get sum from x to y in c++

// 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;
Posted by: Guest on April-12-2022

Browse Popular Code Answers by Language