give me program coding for this prog plz

Discussion in 'C' started by parthahir, Aug 29, 2010.

  1. parthahir

    parthahir New Member

    Joined:
    Aug 29, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    how can i interchang any 2 numbers????
    with out taking any variable?????
    plz ans me its urjent
     
  2. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    One way is to use the xor operation, although it doesn't always work:
    Code:
    a^=b;
    b^=a;
    a^=b;
    
    You should find out under what circumstances it doesn't work (by testing that is, not by posting "give me coding plz" somewhere).
     
  3. LordN3mrod

    LordN3mrod New Member

    Joined:
    Sep 4, 2010
    Messages:
    22
    Likes Received:
    11
    Trophy Points:
    0
    Occupation:
    Software Developer
    Location:
    Yerevan, Armenia
    Yet another way is
    a = a + b;
    b = a - b;
    a = a - b;
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice