Duoas 1,025 Postaholic Featured Poster

First: Only include stuff you need. Go ahead and get rid of everything except iostream. (You don't use any I/O manipulators, you don't use any C math functions, you don't read or write to files, and you don't use any std::strings.)

Second: This point probably isn't obvious at first glance, but you should be using int instead of double. All the math taking place is integer arithmetic and all the example output lacks fractional parts.

Third: "Write a program using functions". You are missing functions (well, besides main). Try to divide your program up into simple functional parts:

main(): in a loop, call a function that asks for two numbers and does the assignment stuff, then ask the user if he wants to do it again. If not, quit the loop and quit the program.

functionA(): ask two numbers from the user. In a loop, complete the assignment's 'accumulator' stuff. Print the results.

functionB(): do the stuff that actually modifies the accumulator...

Make sure to come up with better function names than i've given you here. Also, don't use global variables. Make the functions take arguments and return values.

Finally: You need to get out a piece of paper and clearly write down the exact actions that the functionB() takes for each possibility. The accumulator will be modified one of two ways based on whether or not the larger number is odd or even. Do this and you'll breeze through this assignment.