Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

What is printed by each of the following? Assume that all necessary libraries ar

ID: 3535063 • Letter: W

Question

What is printed by each of the following? Assume that all necessary libraries are included in the preprocessor for the code:

char s1[] = "Anderson Cooper";

char s2[] = "Pamela R Anderson";

printf("%s ", strncpy( s2, s1, 8));

Assume the address of the variable x is 1000:

int x;

int *px;

x = 5;

px = &x;

printf(" %d %d",x,*px);

int seq[5];

int i = 0,

array_val = 3;

for (i = 0; i < 5; i++)

{

seq[i] = array_val;

printf("%d ", seq[i]);

array_val *=2;

}

Assume that the address of the array, a, is 2010. Assume the following code:

int a[4];

int ctr;

int val = 0;

int *ptr_a;

ptr_a = &a[0];

for (ctr = 0; ctr <4; ctr++)

{

val +=3;

a[ctr] = (ctr + val);

}

After the code has been executed, identify the values of the following:

a [ 0 ] ____

a [ 1 ] ____

a [ 2 ] ____

a [ 3 ] ____

val _____

*ptr_a

Explanation / Answer

1) Pamela R Anderson Anderson

2)5,5

3)3,6,12,24,48

4)a[0]=3,a[1]=7,a[2]=11,a[3]=15, ptr_a=3 val=12

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote