Using pointer you can directly change the variable without using any extra variable.
bool Swap(int *ptrVal1, int *ptrVal2)
{
if(ptrVal1 == NULL || ptrVal2 == NULL)
return false;
*ptrVal1 = *ptrVal1 + *ptrVal2;
*ptrVal2 = *ptrVal1 - *ptrVal2;
*ptrVal1 = *ptrVal1 - *ptrVal2;
return true;
}
bool Swap(int *ptrVal1, int *ptrVal2)
{
if(ptrVal1 == NULL || ptrVal2 == NULL)
return false;
*ptrVal1 = *ptrVal1 + *ptrVal2;
*ptrVal2 = *ptrVal1 - *ptrVal2;
*ptrVal1 = *ptrVal1 - *ptrVal2;
return true;
}