Tuesday, 22 July 2014

How To Interchange Two Variable Without Using Third Temporaty Variable

This Program Will Interchange The Value Of Two Variables Without Using The Third Temporary Variable..


#include<stdio.h>
#include<conio.h>
main()
      {
       int a,b;
       printf("\n\tEnter 1st Value:==");
       scanf("%d",&a);
       printf("\n\tEnter 2nd Value:==");
       scanf("%d",&b);
       printf("\n\t Before Interchange a=%d\tb=%d",a,b);

       a=a+b;
      b=a-b;
      a=a-b;

      printf("\n\t After Interchange a=%d\tb=%d",a,b);
      getch();
      }

No comments:

Post a Comment