// program to print the sum of all the numbers from the first to the second. #include using namespace std; int main() { int first; int second; int current; int sum; cout << "Enter first number -- "; cin >> first; cout << "Enter second number -- "; cin >> second; // using a while loop sum = 0; current = first; while (current <= second) { sum = sum + current; current = current + 1; } cout << "The sum from "<< first << " to "<< second << " is "<< sum << endl; // using a do-while loop sum = 0; current = first; do { if (current <= second) { sum = sum + current; current++; } } while (current <= second); cout << "The sum from "<< first << " to "<< second << " is "<< sum << endl; // using a for loop sum = 0; for(current = first; current <= second; current++) sum = sum + current; cout << "The sum from "<< first << " to "<< second << " is "<< sum << endl; // without using current sum = 0; cout << "The sum from " << first << " to " << second; while (first <= second) { sum = sum + first; first = first + 1; } cout << " is " << sum << endl; return 0; }