1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

soluveeeeeee

Discussion in 'C++' started by iammadusanka, Sep 11, 2010.

  1. iammadusanka

    iammadusanka New Member

    Joined:
    Sep 11, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    2. First write an algorithm in psedocode and then Implement (in C) an algorithm that computes the number of 1's in the binary representation of a non-negative integer n . For example if n = 15 your program should return 4 since the binary representation of 15 is 1111. The program should be a recursive one, based on the following definition of f(n) , the number of 1's in the binary representation of n :

    f(n) = f((n-1)/2) + 1 if n is odd
    = f(n/2) if n is even
     
  2. NewsBot

    NewsBot New Member

    Joined:
    Dec 2, 2008
    Messages:
    1,267
    Likes Received:
    2
    Trophy Points:
    0
    Sounds like a C++ problem and nothing to do with MFC
     

Share This Page