Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Cargoes that are susceptible to leak from containers are:

Answered: 1 week ago