// Program to show swap of two no’s without using third variable
#include<stdio.h>
#include<conio.h>
void main() {
int a, b;
printf("\nEnter value for num1 & num2 : ");
scanf("%d %d", &a, &b);
a=a+b-(a=b); //Swaping
printf("\nAfter swapping value of a : %d", a);
printf("\nAfter swapping value of b : %d", b);
getch();
}
Bhavesh Nariya 0 Newbie Poster
Nutster 58 Newbie Poster
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster
DonnSchwartz 0 Newbie Poster
nitin1 15 Master Poster
pawar8390 0 Newbie Poster
deceptikon 1,790 Code Sniper Team Colleague Featured Poster
nitin1 15 Master Poster
deceptikon 1,790 Code Sniper Team Colleague Featured Poster
nitin1 15 Master Poster
deceptikon 1,790 Code Sniper Team Colleague Featured Poster
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster
Lardmeister 461 Posting Virtuoso
Nutster commented: You need to assign to b to actually swap. -1
Oddytech 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.