Hi all C++ gurus
i have a little problem with my codes
basically i have 5,6,7,8,9 in my array

i m supposed to come up with a program that will run through the numbers in the array...if any number that is more than 7 will be replaced by 7

therefore it should look like this

original: 5,6,7,8,9
sorted: 5,6,7,7,7

however when i run
it looks like this

original: 5,6,7,8,9
sorted 5,7,7,7,0

can anyone pls help with me this becoz i m rather new in c++??
thanks


Code:
#include <vcl.h>
#include <condefs.h>
#include "MT262io.h"
#define Size 5

#pragma hdrstop

void displayArray (int Array[Size]);
//---------------------------------------------------------------------------

#pragma argsused
int main(int argc, char* argv[])
{

     int MyArray[Size] = {5,6,7,8,9};
    int TopOfUnsorted;
    int IndexOfLargest =7;
    int IndexOfSmallest;
    int Index;
    int TempInt;

    WriteString("Original Array : ");
    displayArray(MyArray);

    for (TopOfUnsorted=Size-1; TopOfUnsorted>0;    TopOfUnsorted = TopOfUnsorted-1)
    {


        for (Index=0; Index<=TopOfUnsorted; Index = Index + 1)
        {
            if (MyArray[Index] >= MyArray[IndexOfLargest])
            {
                Index = IndexOfLargest;
            }


        }
        //-- swap the position of the largest element with the last
        //-- element in the unsorted part of the array
        TempInt = MyArray[TopOfUnsorted];
        MyArray[TopOfUnsorted] = MyArray[IndexOfLargest];
        MyArray[IndexOfLargest] = IndexOfLargest;
    }

    WriteString("Sorted array   : ");
    displayArray(MyArray);


        getchar();
        return 0;
}

    void displayArray(int Array[Size])
{
    int Index;
    for (Index=0; Index<Size; Index = Index + 1)
    {
        WriteIntPr(" ", Array[Index]);
    }
    WriteString("\n");
    return;
}