Question: 6. Correct the following code errors by drawing a line through the erroneous statement and writing a corrected statement on the same line. All

6. Correct the following code errors by drawing a line through the erroneous statement and writing a

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. Part (a) Part (b) Part (c) void } void } void square (int *p) { *p = *p* *p; } main (void) { int x, *p; P = X; X = 13; void main (void) { int x, *p; X = 13; P = &x; square (&p) printf("x^2=%d ", x); square (p) printf("x^2=%d ", x); main (void) { int x; x = 13; square ( *x ) printf("x^2=%d ", x);

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The provided code snippets each contain a few errors in the way pointers are handled with respect to ... View full answer

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 Programming Questions!