Thread: Stuck on a programming problem

  1. #1
    Registered User
    Join Date
    Sep 2012
    Posts
    1

    Stuck on a programming problem

    Hi all just was looking for a bit of advise on a program assignment I
    have and am stuck on. Not asking you to do the whole thing just am wondering how to go about writing the mathematical portion of the program. here it is

    Find the difference between numbers with an odd number of factors and numbers with an even number of factors for all numbers greater than one and less than one million.

    Your program must:

    1. use a conditional operator within a cout statement to determine whether to output the (odd factors) - (even factors) or(even factors) - (odd factors) so as to print to the console a positive difference between the two numbers,
    2. use a for loop that sequentially tests for factors starting at 1 and ending when the loop counter exceeds the number being considered.
    3. use output formatting to display the final output field seven characters wide,
    4. use a "const unsigned int" to store the parameter MAX_VALUE, which indicates the upper limit of numbers being considered,
    5. use increment and decrement operators when your algorithm's logic is incrementing or decrementing variables,
    6. use at most one while loop, one for loop, and one do-while loop
    7. output only the result using the specific format:
      The difference between numbers with odd factors and numbers with even factors is xxxxxxx.<cr>
      where "xxxxxxx" represents the seven-digit-wide output field for your answer, which must be a positive value as per item #4 above.


    Thanks for any advise!

  2. #2
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    To test if a is a factor of b, divide and see if the remainder is non-zero. 2 is a factor of 4, since the remainder of dividing 4 by 2 is zero. 3 is not, because the remainder is 3.

    Other than that, I can't see how anyone can provide you more information without actually doing your homework for you.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Stuck; Beginning C Programming
    By Phoebe in forum C Programming
    Replies: 9
    Last Post: 09-01-2012, 10:02 PM
  2. Stuck on lab problem
    By Maveryc in forum C Programming
    Replies: 2
    Last Post: 10-07-2011, 07:00 PM
  3. C Programming Help.....Newbie Stuck and Confused!!
    By gsxride in forum C Programming
    Replies: 2
    Last Post: 07-18-2011, 09:17 PM
  4. stuck on namespace problem
    By officedog in forum C Programming
    Replies: 5
    Last Post: 11-20-2008, 06:29 PM
  5. Very new to C++ or other programming, stuck on IF's
    By ivanlucrazy in forum C++ Programming
    Replies: 13
    Last Post: 10-16-2003, 08:59 PM