#include <iostream>
usingnamespace std;
int main ()
{
int next = 2 , sum = 1;
while (next <=5)
{
next++;
sum = sum + next;
}
cout << "The sum of 2 through 5 is " << sum << endl;
return 0;
}
#include <iostream>
int main ()
{
int next = 2 ;
int sum = 0 ; // 1; // initialise sum to zero
while (next <=5)
{
sum = sum + next; // add next to sum before incrementing next
next++;
}
std::cout << "The sum of 2 through 5 is " << sum << '\n' ;
}