C-Program to Swap Two Numbers without 3rd Variable

#include<stdio.h>
 
int main() {
	int a, b;
 
	printf("\nEnter value for num1 & num2 : ");
	scanf("%d %d", &a, &b);
 
	a = a + b;
	b = a - b;
	a = a - b;
 
	printf("\nAfter swapping value of a : %d", a);
	printf("\nAfter swapping value of b : %d", b);
 
	return (0);
}

Capture
Output
 
Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s