How can i sort this array pls..

#include<iostream>
#include<algorithm>
using namespace std;
int prompt(int x[]);
void printreverse(int x[]);


int main()
{
	int x[5];
	prompt(x);
	printreverse(x);
	
	system("pause");
	return 0;
}

int prompt(int x[])
{
	
	for(int i=0;i<5;i++)
	{
		cout <<"Enter integers:";
		cin >>x[i];
	}
}



void printreverse(int x[])
{
	for(int i=0;i<5;i++)
	{
		cout <<x[i]<<" ";
	}
	cout <<endl;
}

The most direct way, since you've already included the algorithm header, is to use std::sort().

what type of sorting pls?

Use the suggestion above, although you might want to google sorting for knowledge experience.

You can do this if you want to use std::sort;

#
int main()
{
int x[5];
prompt(x);
printreverse(x);
std::sort(x,x+5);
system("pause");
return 0;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.