Xiana Z.

asked • 09/29/20

What is wrong with the following code? and what will be the rectified version of this code ?

#include <stdio.h>

#include <stdlib.h>

int *get_val(int y) {

int x = 200; x += y;

return &x; }


int main()

{ int *p, y = 10;

p = get_val(y);

printf("%d\n", *p);

exit(0); }

1 Expert Answer

By:

Michael L. answered • 09/30/20

Tutor
5 (70)

Multiple Years Teaching Others & 4.0 Grades in Computer Science

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.