Array Help/Guidance?

Write a program that sorts a given integer array in descending order.
Hello new here and trying to do an array.
Google/Youtube arrays.
Last edited on
Okay I have an array but how do I make it descending? I have it able to print out 1, 2, 3
but would rather have it do
1
2
3.
code below


#include <iostream> //Initalize Iostream
using namespace std;

void printarray(int arg[], int length) { //Print array function
for (int n = 0; n<length; ++n) // array conditons with n at default 0
cout << arg[n] << ' '; //output
cout << '\n';
}

int main()
{
int array[] = { 1, 2, 3 }; // array initalized
printarray(array, 3); // how many numbers to print in the array

}

uhm. If you want it
1
2
3

You just add endl instead of ' ';

cout << arg[n] << endl; //output
Topic archived. No new replies allowed.