small programming confusion in "C"...

This is a discussion on small programming confusion in "C"... within the C Programming forums, part of the General Programming Boards category; in c programming during selection sorting algo... condition below is mentioned as : array[index_of_min] < array[y] Should be replaced with ...

  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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,547
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

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, 01: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

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