Write a function to populate an array with random integers between 0 and 99. Use the following functions of which the prototypes are to be found in stdlib.h
• randomize() – use once to initialize the randomization process
• rand() – generates a random number between 0 and the maximum value for an integer. You can scale the values down by means of the modulus.
Write a function to remove duplicates from an array of integers.
Write a function to sort an array in ascending order .The following is a simple sorting algorithm
Expand|Select|Wrap|Line Numbers
- . int arr[n];
- int i, j, n, temp;
- /* populate the array*/
- for (i = 0; i < n-1; i++)
- for (j = i+1; j < n; j++)
- if (arr[i] > arr[j]) {
- temp = arr[i];
- arr[i] = arr[j];
- arr[j] = temp;
- }
Expand|Select|Wrap|Line Numbers
- int arr[n];
- int low = 0, high = n, mid, value;
- while (low < high) {
- mid = (low + high) / 2;
- if (arr[mid] < value)
- low = mid + 1;
- else
- high = mid;
- }