```
#include<stdio.h>

int *fun();

main()
{
    int *i;
    i=fun();
    printf("cbgg\n");
    printf("%d",*i);
    getch();
}

int *fun()
{
    int k;
    k=5;
    return (&k);
}

```

Though the program written above prints a garbage value for i, yet the the program written below works fine,i.e. the output is absolutely relevant, which is 5. Why is this so?

```
#include<stdio.h>

int inc();

main()
{
    int i;
    i=inc();
    printf(“cbgg\n”);
    printf(“%d”,i);
    getch();
}

int inc()
{
    int k;
    k=5;
    return (k);
}

```