### help me

can some one help me put these in ascending and descending order?

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869`` ``````// Number Sorter #include using namespace std; char menu() { char choice; cout<< "\nNumber Sorter - Created By Ben Tickle"; cout<< "\n\n**************************************\n"; cout<< "\n\n Please choose one of the following:\n"; cout<< "\n\n 1 - Ascending order "; cout<< "\n 2 - Descending order "; cout<< "\n 3 - Exit"; cout<< "\n\n\n**************************************\n"; cout<< "\n\n Enter you choice and press return: "; cin >> choice; return choice; } int main() { int a[5]; char choice; do { choice = menu(); switch (choice) { case '1': cout << "\n\nAscending order" << "\n\n\nPlease enter 5 numbers include spaces:"; cin >> a[0]; cin >> a[1]; cin >> a[2]; cin >> a[3]; cin >> a[4]; for(int i=0;i<5;++i) cout<
Well, simply use sorting, for example Bubble Sort - here it is described simply:

You can also use built-in sorting function if your assignment allows this (I doubt it).

By the way for printing 5 numbers you can use "for" loop instead of printing them in separate line each.
can some run this and tell me why it wont compile?

 ``1234567891011121314151617181920212223242526272829303132`` ``````#include using namespace std; int main() { int data[5] int i,j,temp,temp1; cout<<"Enter 5 Numbers\n"; for(i=0;i<5;i++) { cin>>data[i]; } temp=data[0]; for(i=0;i,5;i++) { for(j=i;j<5;j++) { if(data[i] , data[j]) { temp=data[i]; data[i]=data[j]; data[j]=temp; } } } cout<<"Descending Order\n"; for(i=0;i,5;i++) { cout<
You can use `#include <algorithm> ` and use `std::sort` to sort things, but it is more convenient if you sort numbers, strings etc. when you input them into a vector. and in the previous code you entered when you type the variables in the `for` loops declare them as integers because they are being used in new scopes.
Topic archived. No new replies allowed.