Google Answers Logo
View Question
Q: C language programming exercise I need answer ( Answered 5 out of 5 stars,   0 Comments )
Subject: C language programming exercise I need answer
Category: Computers > Programming
Asked by: lantern81-ga
List Price: $10.00
Posted: 19 Nov 2002 21:14 PST
Expires: 19 Dec 2002 21:14 PST
Question ID: 111069
I need the exact c language code for the following. Write a program
that initializes an array of double and then copies the contents of
the array into two other arrays.( All three arrays should be declared
in the main program.)
To make the first copy, use a function with array notation. To make
the second copy, use a function with pointer notation and pointer
incrementing. Have each function take as arguments, the name of the
target array, and the number of elements to be copied. That is the
function calls would look like this, given the following declarations:

double source[5]= {1.1, 2.2, 3.3, 4.4, 5.5,};
double target1[5];
double target2[5};
copy_arr(source, target1, 5);
copy_ptr(source, target1, 5);
Subject: Re: C language programming exercise I need answer
Answered By: rbnn-ga on 19 Nov 2002 23:47 PST
Rated:5 out of 5 stars
Thank you for the question.

I have implemented the required specification and included the file

Here is the script:

% gcc copy.c
% ./a.exe

Here is the file copy.c . I have also placed a copy of this file at: 

since sometimes program codes do not render correctly.

As always, if you would like additional features or have any
questions, please solicit these using the "request clarification"
button in your browser before rating the answer.

-----------INCLUDED FILE copy.c---------

#include <stdlib.h>

void copy_arr(double source[], double target[], int len){
  int i;
  for (i=0;i<len;++i)

void copy_ptr(double * source, double * target, int len){
  int i;
  for (i=0;i<len;++i)

int main(){

  double source[5]= {1.1, 2.2, 3.3, 4.4, 5.5,}; 
  double target1[5]; 
  double target2[5]; 
  int i;
  int error=0;
  copy_arr(source, target1, 5); 
  copy_ptr(source, target2, 5);

  for (i=0;i<5;++i)
    if (source[i]!=target1[i]||
      printf("Error at: %d\n",i);
  if (error)

lantern81-ga rated this answer:5 out of 5 stars

There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  

Google Home - Answers FAQ - Terms of Service - Privacy Policy