My teacher want me to create a program called Bubblesort and I dont know how to do it. Plz help me.
And these are description:

4.2.3 ASSIGNMENT: - Bubble Sort Program
In this exercise you will create a bubble sorting algorithm that will sort an array of random numbers in ascending order.

NEW CONCEPTS:
The starter code (below) contains code that will use the current time to “seed” the random number generator and then make calls to the random number generator rand() in order to fill each element in the array.

This code also makes use of a complier directive called #define. This allows the programmer to give a name to a number and then refer to that number by using its name in the body of the program. This way, if it is necessary to change the number, it only needs to be changed in one place. – where it is defined.

SETUP
1. Inside your Array Solution, add a project called Bubble. (File -> Add -> New Project)
2. Create a new cpp file and call it Bubble.cpp.
3. Copy and paste the following code into your Bubble.cpp

#include <iostream>
#include <time.h>
using namespace std;

#define SIZE    10

 int main()
 {
    int nums[SIZE];
    int i;         
    int j;
    int temp;


    //
    // Populate the array with random numbers
    //
    srand( (unsigned)time( NULL ) );
    for(i=0; i<SIZE; i++) {
        nums[i] = rand();
    }

    //
    // Display the array with each element separated by a space
    //


    //
    // Sort the Array
    //


    //
    // Display the sorted array with each element separated by a space
    //


    return 0;
 }

KEY CONCEPTS:
The bubble sort starts at the beginning of the array and compares the first two numbers if the number on the right is less than the number on the left, the numbers are exchanged. Then it proceeds to compare the first number with the 3rd and then the first with the 4th, etc… After all comparisons, it moves to the second number and compares that with each element to the right.

In the example below, each step is shown in the sorting of 6 numbers. The bold numbers are the ones being compared. If the bold number to the right is greater, then the numbers are swapped and the resulting array is shown on the next line. This continues until each number has been compared with all others.


REFERENCE: C++ Beginners Guide, Project 4-1: Sorting an Array

YOUR TASK:
1. After you copy and paste the above code into your Bubble.cpp file, you will add code under each of the three comment blocks. Use the variables that are provided. You should not need any more or any fewer. Do not delete any of the code or comments. Simply add your own code where called for.
2. Your code should do what the comment above the code block says it should do.
3. Your output should consist of two lines of random numbers separated by spaces. In the second line the random numbers will be sorted with the smallest on the left and the largest on the right.

EXAMPLE OUTPUT
5379 26580 19896 57 32411 14962 14310 27342 21949 14761
57 5379 14310 14761 14962 19896 21949 26580 27342 32411


And the program must be the same.
Thanks

Bubble Sort is a very simple algorithm. What seems to be the issue?

What kind of research have you done?

Other than building a program shell, what have you done so far?

Oh, and use code tags...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.