help with c programme

H

holla

Write the following functions that can be called by a C program:

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
.. 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 > arr[j]) {
temp = arr;
arr = arr[j];
arr[j] = temp;
}

Write a function that will merge the contents of two sorted (ascending
order) arrays of type integer values, storing the results in an array
output parameter (still in ascending order). The function should not
assume that both its input parameter arrays are the same length, but
can assume that one array does not contain two copies of the same
value. The result array should also contain no duplicate values.
Write a function to execute a binary search algorithm to search for a
value in an array. Use the following algorithm

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;
}

low will now be the index where value can be found.
 
J

johns

Tell your CS prof that we would much rather
write a game called Gothic 4, where, after
selecting Xardas 3rd option and opening the
portal to the Unknown Lands, we establish
a new home for the humans, but we have to
hire Orcs to help us clear the new land of
cute Cannibal Amazons. Once again Xardas,
being the horney old bastard that he is,
abandons us and joins the ranks of the
evil ladies and their drones. And I set out
on a quest with my Orc friend, Kerpoth, to
find their Queen ....

johns
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top