Help with Do While loops

So honestly I thought I was right on this one, but apparently I'm not. I have to make a Do while loop that will output the sum of the square of the even numbers between and including the firstVar and the secondVar. I cound eaily do this in a while loop but he wants in a do while...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
//Part D
	sumOfVar = 0;
	do {
		if (firstVar % 2 == 0) 
		{
			counter = firstVar;
		}
		else
		{
			counter = firstVar +1; 
		}

	} while (counter <= secondVar);
	{
		sumOfVar = sumOfVar + (counter * counter);
		counter = counter + 2;
	}
	cout << endl << "Part D: " << endl << "The sum of the even square integers between and including " << firstVar << " and " << secondVar << " are: " << sumOfVar << endl;
I cound eaily do this in a while loop

Okay, show us the code with a while loop and then maybe someone can help you convert that code to a do/while() loop.

I got it working after fiddling around and realizing I'm just stupid thanks though!
Topic archived. No new replies allowed.