First method- (using three variables) #include<stdio.h> int main() { int a=10,b=20,c; c=a; a=b; b=c; printf("%d %d",a,b); return 0; } Second method-(using two variables) #include<stdio.h> int main() { int a=10,b=20; a=a+b; b=a-b; a=a-b; printf("%d %d",a,b); return 0; } Third method-(using two variables in single line) #include<stdio.h> int main() { int a=10,b=20; b=a+b-(a=b) ; printf("%d %d",a,b); return 0; }
Comments
Post a Comment
If you have any doubt you ask me in comment section