Array Sortting

This is a discussion on Array Sortting within the C Programming forums, part of the General Programming Boards category; I am a beginer in C, i have a problem that i hope somebody will help me. I put a ...

  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, 08:25 PM
  2. from 2D array to 1D array
    By cfdprogrammer in forum C Programming
    Replies: 17
    Last Post: 03-24-2009, 11: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, 10:54 AM
  5. Quick question about SIGSEGV
    By Cikotic in forum C Programming
    Replies: 30
    Last Post: 07-01-2004, 08:48 PM

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