I need to convert this for loop to a do while:
for (int i = 0; i <= input; i = i + 2)
{
cout << name << " is number " << input << endl;
total = total + i;
}
cout << endl;
cout << total << endl;
This is what I have so far:
do
{
cout << name << " is number " << input << endl;
i += 2;
total += i;
} while (i <= input);
cout << endl;
cout << total << endl;
It doesn't give the same total value as the for loop. What am I doing wrong?
ithe second time around?