Subscribe for more such posts..

Dear Reader...
I hope u are like my posts. If so then please don't forget to like , share and follow my blog for more such posts ,also feel free to write suggestions in the comment box given over here.

Thank you...

Search This Blog

Swapping - without a third variable in C.


#include <stdio.h>

void main() {
	int a, b;
	printf("Enter two integer values : ");
	scanf("%d %d", &a, &b);
	printf("Before swapping the values are a = %d, b = %d\n", a, b);
    a = a + b ;
    b  = a - b ;
    a = a - b ;
    
	printf("After swapping the values are a = %d, b = %d\n", a, b);
}


No comments:

Post a Comment