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

hw3.pdf (page 1 of 2) Q Search 6. Correct the following code errors by drawing a

ID: 3585888 • Letter: H

Question

hw3.pdf (page 1 of 2) Q Search 6. Correct the following code errors by drawing a line through the erroneous statement and writing a corrected statement on the same line. All versions should print "X"2-169". The only change you can make to the code is the placement of“*" and "&” symbols. No other changes are permitted. void square (int *p) *p= *p * *p; Part (a) void main (void) int x, pi p= x; x13; square( p) printf ("x 2-d ", x) Part (b) void main (void)t int x, *pi x= 13; p= &x; square (&p; printf ("x^2-%d ", x); Part (c) void main (void) int x; x= 13; square ( *x ) printf("x^2=%d ", x);

Explanation / Answer

Please find my answer.

PArt(a)

void main(void) {

int x, *p;

error => p = x; correct : p = &x;

x = 13;

square(p);

printf("x^2=%d ", x);

}

Part (b):

void main(void) {

int x, *p;

x = 13;

p = &x;

error => square(&p); correct: square(p);

printf("x^2=%d ", x);

}

Part (c):

void main(void) {

int x;

x = 13;

error => square(*x); correct : square(&x);

printf("x^2=%d ", x);

}