swap two numbers
public static void main(String[] args) { int x = 10; int y = 20; x=x+y; y=x-y; x=x-y; System.out.println("x:"+x+" y:"+y); }
swap two numbers
public static void main(String[] args) { int x = 10; int y = 20; int temp; temp = x; x = y; y = temp; System.out.println("x:"+x +" y:" + y); }
program to swap two numbers
#include<stdio.h> int main() { int x = 20, y = 30, temp; temp = x; x = y; y = temp; printf("X = %d and Y = %d", x, y); return 0; }
Source: devsenv.com