COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### write a c programme

• Email
• Follow

`Write the following functions that can be called by a C program:Write a function to populate an array with random integers between 0and 99. Use the following functions of which the prototypes are to befound in stdlib.h=B7	randomize() - use once to initialize the randomization process=B7	rand() - generates a random number between 0 and the maximum valuefor 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 isa simple sorting algorithm.. int arr[n];int i, j, n, temp;/* populate the array*/for (i =3D 0; i < n-1; i++)   for (j =3D i+1; j < n; j++)      if (arr[i] > arr[j]) {	temp =3D arr[i];	arr[i] =3D arr[j];	arr[j] =3D temp;     }Write a function that will merge the contents of two sorted (ascendingorder) arrays of type integer values, storing the results in an arrayoutput parameter (still in ascending order). The function should notassume that both its input parameter arrays are the same length, butcan assume that one array does not contain two copies of the samevalue. The result array should also contain no duplicate values.Write a function to execute a binary search algorithm to search for avalue in an array. Use the following algorithmint arr[n];int low =3D 0, high =3D n, mid, value;while (low < high) {	mid =3D (low + high) / 2;	if (arr[mid] < value)	    low =3D mid + 1;     else          high =3D mid;     }low will now be the index where value can be found.`
 0
Reply s26463068 (1) 3/14/2007 1:42:28 PM

See related articles to this posting

`holla wrote:> 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.hYou have posted to the wrong newsgroup (Java instead of C),or you are attending the wrong course (C instead of Java).-- Thomas`
 0

`holla wrote:> 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.> This belongs in comp.lang.c.This also looks suspiciously like a homework question...`
 0

`holla wrote:> Write the following functions that can be called by a C program:Erm, no.`
 0

```In article <Gc0Kh.1401\$Eg4.727@trnddc03>,
Joshua Cranmer  <example@example.com> wrote:
>holla wrote:
>> 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

randomize() is not in <stdlib.h> (nor in any other C89 header)

>> �	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.

C's rand() has a maximum value of RAND_MAX (which is in <stdlib.h>),
not "the maximum value for an integer").

>This belongs in comp.lang.c.

Not really -- in comp.lang.c we handle questions about what is
or is not standard C, but we do not get into particular algorithms
except to discuss the extent to which they are C or not.

>This also looks suspiciously like a homework question...

In comp.lang.c, we especially don't do homework programs.
If someone posts a partial attempt and has -specific- questions
they might get answered, if the questions have to do with C-isms,
rather than being questions about the algorithm.

There is an algorithm newsgroup and there are programming newsgroups;
that just -happen- to have been written in C but do not have any
C-specific properties.
--
I was very young in those days, but I was also rather dim.
-- Christopher Priest
```
 0
Reply roberson2 (8606) 3/15/2007 2:10:33 AM

```roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote:

> Joshua Cranmer  <example@example.com> wrote:
> >This belongs in comp.lang.c.
>
> Not really -- in comp.lang.c we handle questions about what is
> or is not standard C, but we do not get into particular algorithms
> except to discuss the extent to which they are C or not.

I wouldn't go that far.

> >This also looks suspiciously like a homework question...
>
> In comp.lang.c, we especially don't do homework programs.
> If someone posts a partial attempt and has -specific- questions
> they might get answered, if the questions have to do with C-isms,
> rather than being questions about the algorithm.
>
> There is an algorithm newsgroup and there are programming newsgroups;
> that just -happen- to have been written in C but do not have any
> C-specific properties.

Well... yes and no. If the algorithm has been implemented in C, but
there is doubt about whether that C implementation of the algorithm is
correct, that's perfectly on-topic. _Pure_ algorithm problems are not,
that much I'll agree with.

We still don't (or shouldn't) do homework problems, though.

Richard
```
 0
Reply rlb (4118) 3/16/2007 12:54:43 PM

5 Replies
125 Views

Similar Articles

12/12/2013 10:00:15 AM
page loaded in 207143 ms. (0)

Similar Artilces:

Writing a C/C++ compiler in C++
I've been thinking of writing a C++ compiler in C++ over the next several years, and I was wondering what's changed in writing a compiler? I've been pouring over these groups and there seems to be a lot of tools for starting but is the modern process still the same? As far as I understand it you write a lexer that tokenizes all the symbols, then write a parser that parses all of the tokens, then walks the parse tree to generate the asm or IL that gets shoved to the backend. So it seemed straightforward except that C++ isn't a LALR(1) grammer that Bison or Byacc accepts. Does ...

Is the average IQ of C programmers less than that of C++ programmers?
I have a feeling that their EQ will show to be significantly lower. Feel free to post your IQs and EQs! On Tuesday, March 29, 2011 5:19:46 AM UTC+1, MikeP wrote: > I have a feeling that their EQ will show to be significantly lower. Feel > free to post your IQs and EQs! That would make C a better language for commercial purposes, wouldn't it? When I worked as a programmer, the management attitude was that they didn't want clever code; they wanted code that other staff could maintain and develop as easily as its author, especially after he had gone. On that basis, the...

US-NH: Concord-C# Developer - C# Engineer - C# Programmer
************************************************************** JobCircle.com is the largest regional job board in the Mid-Atlantic region, with tens of thousands of job offerings in PA, NJ, DE, MD, NY, and Washington D.C. To learn more, visit http://www.jobcircle.com?source=ng ************************************************************** Job Title: C# Developer - C# Engineer - C# Programmer - C# -... Job Location: NH: Concord Pay Rate: competitive Job Length: full time Start Date: 2010-12-08 Company Name: Cybercoders Contact: Shea Stone Phone: ...

US-NH: Concord-C# Developer - C# Engineer - C# Programmer
************************************************************** JobCircle.com is the largest regional job board in the Mid-Atlantic region, with tens of thousands of job offerings in PA, NJ, DE, MD, NY, and Washington D.C. To learn more, visit http://www.jobcircle.com?source=ng ************************************************************** Job Title: C# Developer - C# Engineer - C# Programmer - C# -... Job Location: NH: Concord Pay Rate: competitive Job Length: full time Start Date: 2010-12-08 Company Name: Cybercoders Contact: Shea Stone Phone: ...

Writing a C++ compiler in C++
Any projects out there which aim to write a real or experimental C++ compiler or interpreter using the C++ language itself? Adem schrieb: > Any projects out there which aim to write a real or experimental > C++ compiler or interpreter using the C++ language itself? Most C++ compilers are based on C, because it's hard enough to make C programs run on multiple platforms. Using C++ will increase that incompatibility again. AFAIK gcc will be compiled three times, until the compiler is usable on a different platform. The bootstrap process uses the C compiler of the platform for the fi...

C, C++, C#.NET Programmers need in Michigan
VisionIT is seeking up to 25 C Programmers (C, C++, C#.NET) for its client in Lansing and Troy, Michigan. Positions are on a 6 month contract to hire basis and are paying \$42.31 per hour. Our client has been awarded seven new Medicaid contracts in Kentucky, Oregon, Alabama, Florida, Wisconsin, Connecticut and Massachusetts and they require resources to help get things up and running. Required Skills: 3-5 years, C/C++/C# programming experience, plus basic UNIX Command knowledge, and familiarity with SQL VisionIT Wants You! VisionIT is all about connecting the right candidate with the right ...

Books on C/C++ for perl programmers
There are many books on "perl for C/C++ programmers" but none for "C/C+ + for perl programmers". Does anyone know of any such book or tutorial? Thanks in advance, >Hanna< On Apr 28, 4:27=A0am, l0cl <taurusgemini...@gmail.com> wrote: > + for perl programmers". Does anyone know of any such book or > tutorial? I don't think that they are any, but that's not a problem. There are many, many books on C and C++, and we each have our favorites. I can vouch personally for a dozen or so, but I won't. Most of them will probably get you into C or...

Looking for a C/C++ programmer in Houston
Hi all - I have a short-term project which requires the skills of an experienced C/C++ developer... The project involves redesigning a DLL that uses polling to read data from both TCP/IP sockets and Serial Ports and places the data in a memory-mapped file for use by other applications. The goal is to rework the DLL to provide multi-threaded, event driven reading of the ports (both IP and Serial) and place the data into a shared space (this could be the old mapped file or a stream solution) in order to increase efficiency and stability. The project is expected to take about two wee...

Looking for a C/C++ programmer in Houston
Hi all - I have a short-term project which requires the skills of an experienced C/C++ developer... The project involves redesigning a DLL that uses polling to read data from both TCP/IP sockets and Serial Ports and places the data in a memory-mapped file for use by other applications. The goal is to rework the DLL to provide multi-threaded, event driven reading of the ports (both IP and Serial) and place the data into a shared space (this could be the old mapped file or a stream solution) in order to increase efficiency and stability. The project is expected to take about two wee...

For Free Download lectures and Presentation of Programming and many more related to the field of Computer Science. Visit http://computerscienceppt.blogspot.com/ This Blog Contains a Collection of Lectures of about more then 80 subjects related to the field of Computer Science. -- [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ] On Nov 2, 10:24 pm, alamzeb123 <alamzeborak...@gmail.com> wrote: > For Free Download lectures and Presentation of Programming and many > more related...

Informational Link For C/C++ Programmers and Beginners
For Free Download lectures and Presentation of Programming and many more related to the field of Computer Science. Visit http://computerscienceppt.blogspot.com/ This Blog Contains a Collection of Lectures of about more then 80 subjects related to the field of Computer Science. ...

US-PA: Horsham-C/C++ Programmer
************************************************************** JobCircle.com is a regional job board serving all industries and occupations in the PA, NJ, DE, NY, MD, and DC areas. We offer a regional job board, online learning, and regional job fair events for jobseekers who live in our areas of focus. To Learn More: Job Board: http://www.JobCircle.com?source=ng eLearning: http://www.JobCircle.com/courseware?source=ng Job Fairs: http://JobCircleJobFairs.com?source=ng ************************************************************** Job Title: C/C++ Programmer Job Lo...

Write C++ wrappers of C code automatically
Hello, I have a quite large library of datastructures implemented in C. All the datastructures are implemented like this: /***************************************/ //header file: typedef struct my_struct my_type; //implementation struct my_struct { // fields in the struct } my_type * my_alloc( /* input_args */ ) { // Create and initialize a my_struct instance. } void my_free( my_type * instance ) { // Free the instance along with all it's fields. } // And then various set/get/do_whatever functions /**************************/ I.e. everythin...

US-NY: New York-C++/UNIX and UNIX/C Senior Developers/Programmers-Multithrea
************************************************************** JobCircle.com - Careers, Content and Community for Technology professionals in the Northeastern United States! Jobcircle.com provides resume submission, classified searches, eLearning, hundreds of career development articles, tech news, and more to tens of thousands of Technology professionals in your area - visit us today at http://www.jobcircle.com! !!! Voted a TOP 50 Career Web Site in 2002 by CareerXRoads !!! ************************************************************** Job Title: C++/UNIX and UNIX/C Senior Developers...

US-NY: New York-UNIX Programming-C++ Programmers Developers-Senior-UNIX / C, #2
************************************************************** JobCircle.com is a regional job board serving all industries and occupations in the PA, NJ, DE, NY, MD, and DC areas. We offer a regional job board, online learning, and regional job fair events for jobseekers who live in our areas of focus. To Learn More: Job Board: http://www.JobCircle.com?source=ng eLearning: http://www.JobCircle.com/courseware?source=ng Job Fairs: http://JobCircleJobFairs.com?source=ng ************************************************************** Job Title: UNIX Programming-C++ Pr...

how to encrypt a C data and write a bin file and read a bin at run time and decrypt C data
Dear All, How to encrypt a C data file and make binary file and then have to read a bin file at run time and decrypt the file and have to read the data. Any help to achive this pls. Would be great if any sample source code provided. Thanks, Sweety sweety wrote: > Dear All, > > How to encrypt a C data file and make binary file and then have to read > a bin file at run time and decrypt the file and have to read the data. > > Any help to achive this pls. Would be great if any sample source code > provided. > > Thanks, > Sweety > I don't really know w...

Help in this programm in C
Hi.I am started learning Programm language C before some time.I am trying to make a programm about a very simple "sell shop".This programm hasn't got any compile problem but when i run it i face some other ploblems which i can not correct.I would appreciated if someone take a look at my programm so as to help me.I tried many times to find out where my mistakes are but i didn't manage something. I have made some comments due to the programm so as to make it more easy to as. Any recommendations about my writing style in the programm are acceptable. Please help me!!! Programm ...

writing GUI in C++
Hi everyone I know this not necessarily the best newsgroup to ask that sort of question but please be nice ;-) as I am not too sure where to start with this problem. I use c++ for my work but always write applications that didn't need GUI. And know there's a project for which I'd need to have one. I looked around on the net and it's really incredible to see that there's nothing really clearly written about the subject. The OS that I use is Linux and i already know that I can use things like Qt, gtk to quickly develop GUI. The problem is that I need the interface to have a...

write functions in C
hey folks, anyone plzzz help me out with this...... 1. Write a function to compress one row of an image. Assume every value is repeated. Given a pointer to the row of color values and the length, without instantiating another image buffer, replace the color values with the number of color values in a series followed by the color value. Return the new length of the array (e.g., [50 50 50 251 251 50 50 75 75 75 75] length = 11; becomes [3 50 2 251 2 50 4 75] with a length = 8) 2. Write a function: given a char, return the bits in reversed sequence. Emphasize speed. Thanks in advance wit...

writing programms in languages
write a program in c++ to implement the following -simultaneous equations -Jacobi method Gauss-Seidel iterative method -Crammer's rule -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Thaiwo wrote: > write a program in c++ to implement the following > -simultaneous equations > -Jacobi method > Gauss-Seidel iterative method > -Crammer's rule > Where, O Spammer, do you get off telling us to write programs for you? - -- The science of economics is the cleverest proof of free will yet constructed. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (GNU/Linux) Comment: ...