M
manu
Hi guys,
In an interview I was asked the following question:
The function calculates the square of the number is given
int square(volatile int value)
{
return value*value;
}
His question was Will this function return square of the argument
passed?
I answered him that it will return the square.But he told that it wont
as the argument is volatile.
As per my knowledge the parameter is pushed to the stack and the
function square() will refer to that value even if it is defined as
the volatile.
Can you people throw some insight into this problem?
Manu
In an interview I was asked the following question:
The function calculates the square of the number is given
int square(volatile int value)
{
return value*value;
}
His question was Will this function return square of the argument
passed?
I answered him that it will return the square.But he told that it wont
as the argument is volatile.
As per my knowledge the parameter is pushed to the stack and the
function square() will refer to that value even if it is defined as
the volatile.
Can you people throw some insight into this problem?
Manu