Swapping Values using 3rd Variable : C Programming
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 with code :
Used compiler : Dev CPP
0 comments:
Post a Comment