really need a help!!

sorry, i'm noob in programming and i really need a help.

the question
"There is an array of String type named arrFruits with the following values: pear, banana, apple, cherry, watermelon, papaya. Sort the contents using an appropriate sort routine and display the sorted data from the same array."

writing the coding (C++) with explanation..
thanks alot..
=] god bless
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <iterator>
using namespace std;

ostream_iterator<string> out (cout,"\n");

int main ()
{
	string arr[] = {"pear","banana","apple","cherry","watermelon","papaya"};
	vector<string> arrFruits(arr,arr+6);
	sort(arrFruits.begin(),arrFruits.end());
	copy(arrFruits.begin(),arrFruits.end(),out);
	system("pause");
    return 0;
}
Topic archived. No new replies allowed.