60 638
Assignments Done
97,8%
Successfully Done
In April 2018

Answer to Question #28451 in C++ for mohd azman samer

Question #28451
write c++ program to sort the number in ascending order.
9,2,5,10,1,7,4
Expert's answer
#include <iostream>
using namespace std;

int main() {
int a[7] = {9, 2, 5, 10, 1, 7, 4};
int n = 7;

//Bubble sort
for (int i = 0; i < n; i++)
for (int j = 0; j < n-1; j++)
& if (a[j] > a[j+1]) swap(a[j], a[j+1]);

for (int i = 0; i < n; i++)
& cout << a[i] << " ";
cout << endl;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions