1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

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,012
    Likes Received:
    203
    Trophy Points:
    0
    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