Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

Question

In programming language C, array names are not assignable variables. Therefore, we can't copy an array directly with an assignment statement. As a contrast, objects of struct types can be copied.

The following code snippet illustrates difference:

struct {int i; float f;} x, y;
int a[10], b[10];
y = x; /* Copy x to y, OK */
b = a; /* Illegal assignment */
Now if we wrap an array inside a struct:
typedef int array[5];
typedef struct {array v;} wrapped;
then we can copy a wrapped array with assignment
wrapped wa, wb;
wb = wa; /* Copy wrapped array a to wrapped array b */
Use this idea to implement an array-copying routine:
/* copy (unwrapped) array a to array b */
void array_copy(array a, array b)
{
}

such that when following driver routine executes,

int main()
{
array a = {1,2,3,4,5}, b = {6,7,8,9,10};
printf("Before: b=[%d,%d,%d,%d,%d]n",
b[0],b[1],b[2],b[3],b[4]);
array_copy(a,b);
printf("After: b=[%d,%d,%d,%d,%d]n",
b[0],b[1],b[2],b[3],b[4]);
}

we get the output:
Before: b=[6,7,8,9,10]
After: b=[1,2,3,4,5]

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M9719110

Have any Question?


Related Questions in Computer Engineering

Question suppose you are considering an improvement to a

Question : Suppose you are considering an improvement to a computer program. The improvement is applicable only to a fraction 35% of the program and the speedup of the improved fraction is 15. What is the overall speedup ...

Represent the number obtained by the last you have digits

Represent the number obtained by the last you have digits of your student number in binary, e.g., if your student number is XXX8372 then the question is to represent "8372" in binary. Also, represent the first three digi ...

Of 144 single women 41 had breast cancer 209 who were

Of 144 single women 41% had breast cancer, 209 who were married 52.2% had breast cancer and of 89 life bing with family 59.6% had breast cancer. Find the p value for the relationship?

Please elaborate your understanding about how rfid and nfc

Please elaborate your understanding about how RFID and NFC work. What are the current security considerations and challenges?

Question suppose you are given a set of cities p number of

Question : Suppose you are given a set of cities (p number of cities) and there longitude and latitude coordinates. You need to determine the two closest cities. Write an algorithm to determine the two closest cities. As ...

The business model for jpmorgan chase was change in 2008

The business model for JPMorgan Chase was change in 2008. Could the upside of the strategy have been achieved without exposing JPMorgan Chase the bank?

Assignment 2 windows 8 upgradeby the due date assigned

Assignment 2: Windows 8 Upgrade By the due date assigned, submit your assignment to the Submissions Area. Scenario: You are a consultant for a company that is using Windows 7 as their operating system and are considering ...

When using todays digital cameras file sizes are often

When using today's digital cameras file sizes are often saved in a format that is well over 1 Megabyte. This may be great for high definition photo reproductions but is a disaster for uploading to the web. Images on your ...

Question suppose your system is designed in such a way that

Question : Suppose your system is designed in such a way that your computer needs to wait for some while to check if the channel is clear before transmitting. You take your measurement overtime and you come to find out t ...

Solution must be recursive you are not allowed to use loops

Solution must be recursive. You are not allowed to use loops, or use the Python "in" operator. PYTHON Write a function called first. It is passed a parameter x, that may or may not be a list; if is x is a list it may con ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As