Thread: I don't understand what this is asking!

  1. #1
    C++ beginner
    Join Date
    Jun 2004
    Posts
    66

    I don't understand what this is asking!

    I have a book here, and there are exercises after each chapter. In chapter two - which is basic data types, there is an exercise that tells me to do this:
    Code:
    Here's an exercise for you puzzle fans. Write a program that will 
    prompt the user to enter two different positive integers. Identify in the
     output the value of the larger integer and the value of the smaller 
    integer.
    I have no idea what that is asking me to do. The book is - ivor Horton's Beginning ANSI C++: The complete Language.
    Oh my goodness.

  2. #2
    Registered User
    Join Date
    Jan 2006
    Posts
    19
    It is saying that you let the user enter two positive integers (1,2,3,4,....) and then compare the two and then show the user which one was larger and which one was smaller. This is simple.

  3. #3
    Slave MadCow257's Avatar
    Join Date
    Jan 2005
    Posts
    735
    Get two positive integers from user (you will use cin to get the input, which will be stored in 2 ints)
    Output them in the format "a > b" (you will use cout for this)

    The puzzle is determining the greater integer

  4. #4
    C++ beginner
    Join Date
    Jun 2004
    Posts
    66
    Thanks fellas - I really just wasn't sure what it meant.
    Oh my goodness.

  5. #5
    Registered User
    Join Date
    Apr 2003
    Posts
    2,663
    Hi,

    I learned C++ from that book, and I suggest that you skip the section on Bitwise Operators in Chapter 3. It is too difficult for beginners, and I think it should be in an appendix.

    If you need specific help with sections in that book, I should be able to help.

  6. #6
    C++ beginner
    Join Date
    Jun 2004
    Posts
    66
    Quote Originally Posted by 7stud
    Hi,

    I learned C++ from that book, and I suggest that you skip the section on Bitwise Operators in Chapter 3. It is too difficult for beginners, and I think it should be in an appendix.

    If you need specific help with sections in that book, I should be able to help.
    Thank you for the advice!
    Oh my goodness.

  7. #7
    chococoder
    Join Date
    Nov 2004
    Posts
    515
    bitwise operators are an essential part of the language, if you don't understand them study harder.

    Just because something isn't dead easy doesn't mean you're not supposed to know it.

  8. #8
    C++ beginner
    Join Date
    Jun 2004
    Posts
    66
    Quote Originally Posted by jwenting
    bitwise operators are an essential part of the language, if you don't understand them study harder.

    Just because something isn't dead easy doesn't mean you're not supposed to know it.
    I'm sure they are - but the problem is that the chapter gets very specific with binary code and hex values and I know next to nothing about binary and hex values and such... so it is VERY confusing to me. So I suppose once I get more comfortable with that sort of thing I'll re-visit it.
    Oh my goodness.

  9. #9
    chococoder
    Join Date
    Nov 2004
    Posts
    515
    that's a shortcoming on the part of your teacher and/or study material then. They should have prepared you better.

    Binary is easy. Remember there are two kinds of people, those who can count to 10 and those that can't, and you're halfway there.

    Hex takes some getting used to, but it's just another numeric base too. Base 16 it is, 0-F instead of 0-9.

  10. #10
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    that's a shortcoming on the part of your teacher and/or study material then. They should have prepared you better.
    That is 7stud's point when giving the advice, if you did not notice. The book, according to 7stud, does not prepare beginners well when introducing bitwise operators.
    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

  11. #11
    C++ beginner
    Join Date
    Jun 2004
    Posts
    66
    I think it assumes that you have knowledge of that sort. Though I suppose I understand what the bitwise operators do - I don't think that my understanding of hex, binary and the like will allow me to make much use of them. That is, until I learn about the stuff.
    Oh my goodness.

Popular pages Recent additions subscribe to a feed