Help with homework please

This is a discussion on Help with homework please within the C Programming forums, part of the General Programming Boards category; Code: do { prod = 1; prod = prod * f; }while ( prod <= (2^31-1)); didn't see it earlier ...

  1. #16
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Code:
    do
        {
        prod = 1;
        prod = prod * f;
        }while ( prod <= (2^31-1));
    didn't see it earlier but this is another infinate loop unless f = (2^31-1)

    And what do you want to count?

  2. #17
    Registered User
    Join Date
    Oct 2003
    Posts
    10
    the factors that the integer has.

  3. #18
    Registered User
    Join Date
    Oct 2003
    Posts
    10
    How would you re-write the code ?


    Thank you

  4. #19
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Before starting to count anything, get the basic program right. Thantos already provided you with some feedback, try implementing some of that first. No point trying to run if you can't walk, or so they say.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  5. #20
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Just got reminded that the ^ is not a power operator but a bitwise XOR.

  6. #21
    Registered User
    Join Date
    Oct 2003
    Posts
    10
    Thank you guys for your help. I think I will need your expertise in the near future.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Homework
    By kermi3 in forum C Programming
    Replies: 10
    Last Post: 09-27-2001, 04:49 PM
  2. Homework
    By kermi3 in forum C++ Programming
    Replies: 15
    Last Post: 09-26-2001, 03:16 PM
  3. Homework
    By kermi3 in forum Windows Programming
    Replies: 5
    Last Post: 09-15-2001, 11:48 AM
  4. Homework
    By kermi3 in forum C Programming
    Replies: 0
    Last Post: 09-10-2001, 01:26 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21