C++ sort()
Sorts float array
#include <iostream> #include <algorithm> using namespace std; int main()//from w w w. j a va 2 s .c o m { int j=0, k; char ch; float fpn, farr[100]; do { cout << "Enter a floating point number: "; cin >> fpn; farr[j++] = fpn; cout << "Enter another ('y' or 'n'): "; cin >> ch; } while(ch == 'y'); sort(farr, farr+j); for(k=0; k<j; k++) cout << farr[k] << ", "; cout << endl; return 0; }