arrays
i need to change this array into a bubble sort array. can someone please help?
#include <iostream.h>
void main ()
{
int data[10]= {78, 87, 89, 98, 56, 69, 90, 100, 66, 88};
int i, j, temp;
int sum = 0;
for (j=0; j<9; j++)
{
for (i=j+1; i<10; i++)
if (data[i]<data[j])
{
temp = data[i];
data[i] = data[j];
data[j] = temp;
}
for (i=0; i<10; i++)
cout << data[i] << " ";
cout << endl;
}
cout << "The array elements are:\n";
for (i=0; i<10; i++)
cout << data [i] << " ";
cout << endl;
}
cross posted in
coders_haven
#include <iostream.h>
void main ()
{
int data[10]= {78, 87, 89, 98, 56, 69, 90, 100, 66, 88};
int i, j, temp;
int sum = 0;
for (j=0; j<9; j++)
{
for (i=j+1; i<10; i++)
if (data[i]<data[j])
{
temp = data[i];
data[i] = data[j];
data[j] = temp;
}
for (i=0; i<10; i++)
cout << data[i] << " ";
cout << endl;
}
cout << "The array elements are:\n";
for (i=0; i<10; i++)
cout << data [i] << " ";
cout << endl;
}
cross posted in
coders_haven