My question is rather brief (it's similar to what is at http://www.daniweb.com/forums/thread79268.html). I've writen the program....but...i was just wondering (apart from the program itself) if there would be anyway to verify if what the program did is correct mathematically? I'll post my code if required. Thx and have a good day. Your suppose to write a C++ program that will add up all the odd numbers from 1 through 3579 and all of the even numbers from 522 through 2222. WHILE LOOPS MUST BE USED!!!

The output is to be in the format:

The sum of the odd numbers from 1-3579 is:
The sum of th eeven numbers from 522 through 2222 is:

Recommended Answers

All 2 Replies

Member Avatar for iamthwee

Use the modulus operator to check even and odd numbers.

Then just add them up.

sum = sum + val

etc

ok kool...thx much

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.