Previous      Next

//  Bad Mistake!!
//  Returns the wrong answer now!!

int *threeMultiply (int n)
{
   int r;
   r = (3*n);
   return &r;
}

void main ()
{
   int *x;
   int *y;
   
   x = threeMultiply (9);
   y = threeMultiply (10);
   printf("\nValue of 9*3: %d, 10*3: %d\n", *x, *y);
}

// Sample Output:
//   Value of 9*3: 30, 10*3: 30