Hey im new in C and i am required to create 500 numbers between 100-1000, and store them in an array. Then i need to sort the array with qsort ascending and descending but i have no idea how to use qsort.
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
int main()
{
int arr[500];
int i;
srand(time(NULL));
for(i=0;i<500;i++) {
arr[i] = 100 + rand() % (1000-100+1);
printf("%d\n",arr[i]);
}
return 0;
}
Here is my code. Can someone maybe help me with qsort? im sitting here nearly 4 hours and dont know how to include qsort in this code.
Aucun commentaire:
Enregistrer un commentaire