Thread: small programming confusion in "C"...

  1. #1
    Registered User
    Join Date
    Jun 2010
    Posts
    1

    small programming confusion in "C"...

    in c programming during selection sorting algo...

    condition below is mentioned as :
    array[index_of_min]<array[y]

    Should be replaced with (if expected behaviour is to be considered) :
    array[index_of_min]>array[y]

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    It depends on what you're trying to do

    Use < if you want to sort ascending (for example).
    Use > if you want to sort decending.
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Bush's address
    By VirtualAce in forum A Brief History of Cprogramming.com
    Replies: 51
    Last Post: 09-27-2008, 03:44 PM
  2. how to split long programe in small files
    By umeshjaviya in forum C Programming
    Replies: 11
    Last Post: 04-15-2008, 02:45 AM
  3. want to make this small program...
    By psycho88 in forum C++ Programming
    Replies: 8
    Last Post: 11-30-2005, 02:05 AM
  4. FILES in WinAPI
    By Garfield in forum Windows Programming
    Replies: 46
    Last Post: 10-02-2003, 06:51 PM
  5. yhatzee, small straight
    By uglyjack in forum C++ Programming
    Replies: 2
    Last Post: 06-13-2002, 03:09 AM