Cpp - What is the output: type conversion during function parameter passing?


A function has the following prototype

void func( unsigned int n);  

What happens when the function is called with -1 as an argument?


When called, the value -1 is converted to unsigned int.

The pattern of -1 is interpreted as unsigned, which yields the greatest unsigned value.

On a 32-bit system, -1 has the bit pattern 0xFFFFFFFF, which, when interpreted as unsigned, corresponds to the decimal value 4 294 967 295.