Answer to Question #47952 in C++ for edzel

Question #47952
How to sort in ascending mode
1
Expert's answer
2014-10-17T00:47:19-0400
Solution.

//Connectinglibrary
#include<iostream>
usingnamespace std;

intmain()
{
inta[10], swap;
for (int i = 0; i < 10; ++i )
{
cout <<endl<< "Enter thenumber: ";
cin>> a;
}

for (int i = 0; i < 10; ++i )
{
for( int j = i; j < 10; ++j )
{
if(a[j] < a[i] ) // ascending
{
swap= a[i];
a[i]= a[j];
a[j]= swap;
}
}
}

cout <<endl<< "Result:";
for ( int i = 0; i < 10; ++i )
{
cout << a[i] << " ";
}

cin.get();
//system(“pause”);
return 0;
}[i]



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 the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS