0

This is my code for windows form application. Please help. My task is: Write a Windows Forms Application which enters 10 integer numbers from the keyboard. The App should arrange and visualize the integer numbers into ascending order. Use an array for creating a program part.

int r[10];

        r[0]=System::Convert::ToInt32(textBox1->Text);
        r[1]=System::Convert::ToInt32(textBox2->Text);
        r[2]=System::Convert::ToInt32(textBox3->Text);
        r[3]=System::Convert::ToInt32(textBox4->Text);
        r[4]=System::Convert::ToInt32(textBox5->Text);
        r[5]=System::Convert::ToInt32(textBox6->Text);
        r[6]=System::Convert::ToInt32(textBox7->Text);
        r[7]=System::Convert::ToInt32(textBox8->Text);
        r[8]=System::Convert::ToInt32(textBox9->Text);
        r[9]=System::Convert::ToInt32(textBox10->Text);

        void bubbleSort(int r[10])
    { 

        int temp; 
        int n=10;
        for(int x=0; x<n; x++)

{

    for(int y=0; y<n-1; y++)

    {

        if(r[y]>r[y+1])

        {

            int temp = r[y+1];

            r[y+1] = r[y];

            r[y] = temp;

        }

    }

}

} label1->Text="The numbers in ascending order are: "+ r[10];

1 Answer 1

0

In C++ you cannot define a function inside another function/method. Move bubbleSort() out of the surrounding method.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.