Swap Two variable value without using Third variable – C Program

Swap Two variable value without using Third variable – C Program

write a c program to swap(interchange) value of two variable without using third variable.

#include<stdio.h>
#include<coino.h>

void main()
{
 int a, b,

 printf("Enter the First Vaue A = ");
 scanf("%d",&a);
 printf("\nEnter thr Second Value B = ");
 scanf("%d",&b);
 a=a+b;
 b=a-b;
 a=a-b;
 printf("The value of A = %d",a);
 printf("\nThe value of B =%d",b);

getch();
}

The swap variable value without using third variable c program output is :

Enter the First Vaue A = 25
 
Enter thr Second Value B = 102
 
The value of A = 102
The value of B = 25

 

Author: Meera Academy

Leave a Reply

Your email address will not be published. Required fields are marked *