Swap two int values

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • alexandra69
    New Member
    • Feb 2008
    • 1

    Swap two int values

    i'm new in programing and i do not know, if you can help me with this one...

    Given two int variables, firstPlaceWinne r and secondPlaceWinn er , write some code that swaps their values.

    Declare any additional variables as necessary, but do not redeclare firstPlaceWinne r and secondPlaceWinn er .
  • sicarie
    Recognized Expert Specialist
    • Nov 2006
    • 4677

    #2
    Sure, what do you need help with?

    Comment

    • bykwzpz
      New Member
      • Jan 2008
      • 12

      #3
      Here is a way:

      <Code removed my MODERATOR - Please read our Posting Guidelines>

      Comment

      • Meetee
        Recognized Expert Contributor
        • Dec 2006
        • 928

        #4
        Originally posted by alexandra69
        i'm new in programing and i do not know, if you can help me with this one...

        Given two int variables, firstPlaceWinne r and secondPlaceWinn er , write some code that swaps their values.

        Declare any additional variables as necessary, but do not redeclare firstPlaceWinne r and secondPlaceWinn er .
        It's really very simple. You just need to store one value in temporary variable and swap both. after that value in temp variable can be swaped in another variable!. Just try to write some logic once and the work would be easy :)

        Comment

        • shariquehabib
          New Member
          • Oct 2006
          • 22

          #5
          Originally posted by alexandra69
          i'm new in programing and i do not know, if you can help me with this one...

          Given two int variables, firstPlaceWinne r and secondPlaceWinn er , write some code that swaps their values.

          Declare any additional variables as necessary, but do not redeclare firstPlaceWinne r and secondPlaceWinn er .
          Hi ,
          try this one::
          <CODE REMOVED BY MODERATOR - PLEASE READ OUR POSTING GUIDELINES>

          and print both variables
          Last edited by Ganon11; Feb 20 '08, 04:30 AM. Reason: Removing 'spoonfed' code

          Comment

          • FAUPrideBaby
            New Member
            • Jan 2008
            • 2

            #6
            Originally posted by alexandra69
            i'm new in programing and i do not know, if you can help me with this one...

            Given two int variables, firstPlaceWinne r and secondPlaceWinn er , write some code that swaps their values.

            Declare any additional variables as necessary, but do not redeclare firstPlaceWinne r and secondPlaceWinn er .

            Sure, that's really simple!
            Your code should look something like this.

            Seriously? Two freaking people had their code removed, and messages left, and you think for some reason that you are different, or better, or what?

            Code freaking removed. Read the Guidelines of this site, this is your one warning, cause apparently you have trouble reading anywya.

            Comment

            Working...