Hi all,

I have a assignment that says, write a program that will add up all of the odd numbers from 1 through 3579 and alll of the even numbers from 522 to 2222.

Use While loops.

Output should look like this

The sum of the odd numbers from 1 through 3579 is XXXXXXXXXXX

The sum of the even numbers from 522 through 2222 is XXXXXXXXX.

Where X is the answer.

I started off with the program trying to just ititailize the variables and let the program go but it wasnt doing anything so I made the user input a value in the beginning but I think he just wants it to run on its own with no input from the user.

This is what I have so far.

```
int odd = 1;
int even = 522;
int totalodd = 0;
int totaleven = 0;
int number;
cout << "Enter an intial odd # between 1 - 3579 or an even # between 522 - 2222)" << endl;
cin >> number;
if (number % 2 != 0){
while (odd != 3579){
totalodd = totalodd + odd;
odd + 2;}
}
else if (number % 2 == 0){
while (even !=2222){
totaleven = totaleven + even;
even + 2;
}}
cout << "The sum of the odd numbers from 1 through 3579 is " << totalodd << endl;
cout << "The sum of the even numbers from 522 through 2222 is " << totaleven << endl;
```

as of now it does compile but doesnt do anything after the individual enters a number.

Thanks Alot for the help

*Edited 3 Years Ago by pyTony*: fixed formatting