Swap numbers without using third variable

swap()
{
    int a=20, b=30;
    a=a+b; //a=50 (20+30)
    b=a-b; //b=20 (50-30)
    a=a-b; //a=30 (50-20)
}

Leave a Reply

Your email address will not be published. Required fields are marked *