Tuesday, April 3, 2018

swap two variable without using function or variable

This code is a technique to swap two value without using any extra variable. This is a most common code in software firm.

#include <stdio.h>
#include <conio.h>
int main()
{
  int x = 15, y =1;
  x = x + y; 
  y = x - y; 
  x = x - y;

  printf(" Swapping value : x = %d, y = %d", x, y);

  return 0;
}

No comments:

Post a Comment