How to compare, without using compare (homework)

This is a discussion on How to compare, without using compare (homework) within the C++ Programming forums, part of the General Programming Boards category; Make a program that will compare two values without using relational operators in purely c++ syntax. I know the answer... ...

  1. #1
    Programming King Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Middle of NoWhere
    Posts
    320

    Thumbs up How to compare, without using compare (homework)

    Make a program that will compare two values without using relational operators in purely c++ syntax.


    I know the answer... Just a quiz.... :-)

  2. #2
    The larch
    Join Date
    May 2006
    Posts
    3,573
    I think everybody knows that.
    I might be wrong.

    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
    Quoted more than 1000 times (I hope).

  3. #3
    Programming King Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Middle of NoWhere
    Posts
    320
    :-)
    Me either think like this, but if someone doesn't know, it'll be much better for him to learn this thing.....

    Everyone, don't post the logic until you didn't find anyone who don't know the answer....

  4. #4
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,651
    Like using the word "Challenge" in your title is going to make us magically overlook the fact that you've posted your homework/quiz question here in an attempt to get us to do it for you.

  5. #5
    Programming King Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Middle of NoWhere
    Posts
    320
    Lol..... Don't worry..... I know the answer already.... And it's not my age to do homeworks like these simple tricks :-)

    Anyways, keep it going as it is...

  6. #6
    Registered User
    Join Date
    Aug 2010
    Location
    Poland
    Posts
    682
    Quote Originally Posted by Mr.777 View Post
    I know the answer already....
    Proof?
    I never put signature, but I decided to make an exception.

  7. #7
    Programming King Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Middle of NoWhere
    Posts
    320
    Proof is
    suppose x and y are two inputs...
    Code:
    if(x/y){
    cout<<y<<"is greater"<<endl;
    }
    else{
    cout<<x<<"is greater"<<endl;
    }
    Sorry i just read your reply as my thread was on second page...

    Got it.. :-)

  8. #8
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,659
    Smooth - I input y = 0
    Your move...
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  9. #9
    Programming King Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Middle of NoWhere
    Posts
    320
    @Salem: I think one should handle errors before everything...
    So, that's what everyone does....

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. help about homework
    By agathery in forum C Programming
    Replies: 27
    Last Post: 05-19-2010, 09:17 PM
  2. compare with chars && compare with int
    By zcrself in forum C Programming
    Replies: 1
    Last Post: 04-22-2010, 03:19 AM
  3. compare strings not working
    By gtriarhos in forum C Programming
    Replies: 7
    Last Post: 09-29-2005, 12:51 PM
  4. Help Writing My Own String Compare
    By djwicks in forum C Programming
    Replies: 4
    Last Post: 04-07-2005, 09:44 PM

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