C Program To Swap Two Variable Without Using Third Variable

C Program To Swap Two Variable Without Using Third Variable

/*Program To Swap Two Variable Without Using Third Variable*/

/**************First Method**************************/
#include <stdio.h>
int main()
{int a,b;
printf("Enter The Value Of a:--");
scanf("%d",&a);
printf("Enter The Value Of b:--");
scanf("%d",&b);
a=a+b;
b=a-b;
a=a-b;
printf("After Swaping!!");
printf("\nValue Of a:--");
printf("%d",a);
printf("\nValue Of b:--");
printf("%d",b);
  return 0;

}

/**************Second Method************************/
#include <stdio.h>
int main()
{int a,b;
printf("Enter The Value Of a:--");
scanf("%d",&a);
printf("Enter The Value Of b:--");
scanf("%d",&b);
a=a*b;
b=a/b;
a=a/b;
printf("After Swaping!!");
printf("\nValue Of a:--");
printf("%d",a);
printf("\nValue Of b:--");
printf("%d",b);
  return 0;

}

Post a Comment

0 Comments