Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / March 2007

Tip: Looking for answers? Try searching our database.

write a c programme

Thread view: 
holla - 14 Mar 2007 14:42 GMT
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[i] > arr[j]) {
    temp = arr[i];
    arr[i] = 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.
Thomas Fritsch - 14 Mar 2007 15:06 GMT
> 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
You have posted to the wrong newsgroup (Java instead of C),
or you are attending the wrong course (C instead of Java).

Signature

Thomas

Joshua Cranmer - 15 Mar 2007 01:13 GMT
> Write the following functions that can be called by a C program:
>
[quoted text clipped - 43 lines]
>
> low will now be the index where value can be found.

This belongs in comp.lang.c.

This also looks suspiciously like a homework question...
Alex Hunsley - 15 Mar 2007 01:55 GMT
> Write the following functions that can be called by a C program:

Erm, no.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.