Thread: help with assignment

  1. #1
    Registered User
    Join Date
    May 2019
    Posts
    1

    help with assignment

    Hello everyone!

    I ask you to guide me what to do with the binary operations assignment.

    Your program will receive two inputs:
    - an integer number that represents a value;
    - an integer number that represents bit position;

    You program shall answer “YES” if there is a “1” in given position of the value. Otherwise, it
    shall return “NO”.

    Explanation: Your program receives 5 and 2. “5” is a value and “2” is a position. Let’s write
    number 5 in binary and show positions:

    Binary 00000101
    Position 76543210

    So, we see that, for number 5, the position 0 is “1”, position 1 is “0” and position 2 is “1”. Therefore the answer is “YES”. If position was 1, then the response should be
    “NO”.

    Can you help please? I have no idea what to write.

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Have you revised your learning material on bitwise operations such as bit shifting and bitwise and?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    TEIAM - problem solved
    Join Date
    Apr 2012
    Location
    Melbourne Australia
    Posts
    1,907
    Start by
    Printing a welcome note, instructions for the user.
    Once you have that working, get 2 integers from the user

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help with an assignment
    By Jordan Velez in forum C++ Programming
    Replies: 3
    Last Post: 04-08-2015, 12:48 PM
  2. Assignment help !
    By Adam_Amaral in forum C Programming
    Replies: 10
    Last Post: 10-14-2011, 04:22 AM
  3. Car assignment help
    By anik18 in forum C Programming
    Replies: 4
    Last Post: 05-09-2009, 09:40 PM
  4. Replies: 3
    Last Post: 04-26-2009, 08:54 AM
  5. need help with an assignment
    By iftekharx in forum C Programming
    Replies: 3
    Last Post: 06-25-2005, 02:33 AM

Tags for this Thread