Question: 1 . Draw memory diagrams for point one, two, three, and four. 2 . Add labels to diagram at point two to indicate the size

1. Draw memory diagrams for point one, two, three, and four.
2. Add labels to diagram at point two to indicate the size in bytes for each variable, array, and function argument.
#include
void try_to_change(double* dest);
void try_to_copy(double dest[], double source[]);
double add_them (double a[5]);
int main(void)
{
double sum =0;
double x[4];
double y[]={2.3,1.2,2.0,4.0};
printf(" sizeof(double) is %d bytes.
",(int) sizeof(double));
printf(" size of x in main is: %d bytes.
",(int) sizeof(x));
printf(" y has %d elements and its size is: %d bytes.
",
(int)(sizeof(y)/ sizeof(double)),(int) sizeof(y));
/* Point one */
try_to_copy(x, y);
try_to_change(x);
sum = add_them(&y[1]);
printf("
sum of values in y[1], y[2] and y[3] is: %.1f
", sum);
return 0;
}
void try_to_copy(double dest[], double source[])
{
dest = source;
/* point two*/
return;
}
void try_to_change(double* dest)
{
dest [3]=49.0;
/* point three*/
printf("
sizeof(dest) in try_to_change is %d bytes.
",(int)sizeof(dest));
return;
}
double add_them (double arg[5])
{
*arg =-8.25;
/* point four */
printf("
sizeof(arg) in add_them is %d bytes.
",(int) sizeof(arg));
printf("
Incorrect array size computation: add_them says arg has %d"
" element.
",(int)(sizeof(arg)/ sizeof(double)));
return arg[0]+ arg[1]+ arg[2];
}
I have included a pciture of how I did it and im not sure if its right
 1. Draw memory diagrams for point one, two, three, and four.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!