Thread: Array Sortting

  1. #1
    Registered User
    Join Date
    Nov 2002
    Posts
    3

    Angry Array Sortting

    I am a beginer in C, i have a problem that i hope somebody will help me.
    I put a numbers of value in the array such as (a long list);

    x[0]=10;
    x[1]=20;
    x[2]=5;
    x[3]=15;
    x[4]=8;

    i need to find out which array have the smallest value, so the answer is array number #2. ( i need array number, not the value in the array).

    how should i do to use "for" looping ?

    Thanks,

  2. #2
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    You're thread title is about "sorting" then you ask how to find the smallest value. That's two different things, so which do you _really_ want to do?

    The find the smallest value, simply loop through the array, checking each element. There are numerous examples of "for" loops on the forum, even some doing exactly as you require. Do a search and see what you can find.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 16
    Last Post: 05-29-2009, 07:25 PM
  2. from 2D array to 1D array
    By cfdprogrammer in forum C Programming
    Replies: 17
    Last Post: 03-24-2009, 10:33 AM
  3. Replies: 6
    Last Post: 11-09-2006, 03:28 AM
  4. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  5. Quick question about SIGSEGV
    By Cikotic in forum C Programming
    Replies: 30
    Last Post: 07-01-2004, 07:48 PM