Hi. Here's my code:
It compiles without errors but does not sort the array. What am I doing wrong? Thanks.Code:#include <iostream> using namespace std; const int ELEMENTS = 4; int main() { int num[4]; int n; int i; int j; int temp; int *Ptr = NULL; for(n = 0; n < ELEMENTS; n++) { cout << "Type a number: "; cin >> num[n]; } Ptr = num; for(i = 0; i < ELEMENTS; i++) for(j = 0; j < ELEMENTS - 1; j++) if(*(Ptr + i) < *((Ptr + j) - 1)) { temp = num[j]; *(Ptr + j) = *((Ptr + j) - 1); *((Ptr + j) -1)= temp; } for(i = 0; i < 4; i++) cout << num[i] << endl; return 0; }