For the above program, code goes like this :
/* Swapping values without using 3rd Variable */
#include<stdio.h>
main()
{
int a,b;
printf(" Enter two numbers :");
scanf("%d %d",&a,&b);
printf("\n The values of a & b before swapping values is %d & %d",a,b);
a=a+b;
b=a-b;
a=a-b;
printf("\n The values of a & b after swapping the values is %d & %d",a,b);
}
Output :
Compiler used : Dev CPP
Home / C Language /
C Program /
Swapping Values without 3rd Variable /
Variables
/ Swap Values Without Using 3rd Variables : C Programming
- Blogger Comment
- Facebook Comment
Subscribe to:
Post Comments
(
Atom
)
0 comments:
Post a Comment