Thread: switching value of variable?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Jul 2011
    Posts
    10

    Angry switching value of variable?

    I'm trying to ru this code however it's not working for me. I need to switch the value of "x" with the value of "y" if (x<y) however it's not working the way I wrote it. Does anyone have any suggestions?

    Code:
    
    { 
    
    
        int x=0;
        int y=0;
        int temp=0;
        int remainder=0;
    
        // read in the two integers
    
        cout << endl ;
         cout << "Enter the first number (integer) : " ; 
        cin >> x ;
         cout << "Enter the second number (integer) : " ; 
        cin >> y ;
     
        //echo inputs
     
        cout << "Input numbers are: " << x << " , " << y << endl;
    
        if ( x < y) 
    
    		
        
           { // exchange values of x and y 
    
    		 temp=x;
    		 x = y;
    		 y==temp;
          
    
     }
    Last edited by genesis531501; 07-25-2011 at 09:01 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Switching to RGB from GRB
    By HQSneaker in forum Game Programming
    Replies: 20
    Last Post: 09-28-2004, 07:48 AM
  2. Switching hardrives
    By incognito in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 03-01-2003, 09:42 PM
  3. About variable type switching..
    By Dragonlord in forum C Programming
    Replies: 6
    Last Post: 08-31-2002, 05:22 PM
  4. Switching arrays
    By Unregistered in forum C Programming
    Replies: 1
    Last Post: 02-18-2002, 02:55 PM
  5. switching
    By iain in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 08-11-2001, 08:29 AM