1.

Swap two int with temp variable and without temp variable

Answer»

Below SOURCE code will help you to swap values between two INTEGER with help of temp variable and without temp variable
//define two variable
int i=2;
int j=6;

//with temp varible
int temp //as a temp varible
//swapping
int temp=i; //swap first variable to temp variable
int i=j; //swap value of SECOND variable to first
j=temp //swap temp to second varible

//without temp varible
i=i+j; //ADD both number
j=i-j; //subtract second from first
i=i-j; //subtract second from first



Discussion

No Comment Found