Forum

Number Of Page View:100,000+/Months
LOGIN |New User

Reply

how to switch the values of two variable without using third variable?
I have given a example which switch the values of two variables without using third variable.   

#include<stdio.h>
void main()
{
  int val1,val2;
  val1=5;
  val2=6;
  /* now adding val2 to val1 we have */;
  val1=val2+val1;
  val2=val1-val2; 
/* now here val2 will get value of val1 */;
  val1=val1-val2 
/*this will give val1 value of val2 */;
}