#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,t;
clrscr();
printf("Enter two values:\n");
scanf("%d%d",&a,&b);
printf("\n\nBefore swapping %d %d\n\n",a,b);
t=a;
a=b;
b=t;
printf("After swapping %d %d",a,b);
getch();
}
out put : Enter two values: 1 2
Before swapping 1 2
After swapping 2 1
( OR )
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
clrscr();
printf("Enter two values:\n");
scanf("%d%d",&a,&b);
printf("\n\nBefore swapping %d %d\n\n",a,b);
a=a*b;
b=a/b;
a=a/b;
printf("After swapping %d %d",a,b);
getch();
}
out put : Enter two values: 1 2
Before swapping 1 2
After swapping 2 1
( OR )
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
clrscr();
printf("Enter two values:\n");
scanf("%d%d",&a,&b);
printf("\n\nBefore swapping %d %d\n\n",a,b);
a=a+b;
b=a-b;
a=a-b;
printf("After swapping %d %d",a,b);
getch();
}
#include<conio.h>
void main()
{
int a,b,t;
clrscr();
printf("Enter two values:\n");
scanf("%d%d",&a,&b);
printf("\n\nBefore swapping %d %d\n\n",a,b);
t=a;
a=b;
b=t;
printf("After swapping %d %d",a,b);
getch();
}
out put : Enter two values: 1 2
Before swapping 1 2
After swapping 2 1
( OR )
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
clrscr();
printf("Enter two values:\n");
scanf("%d%d",&a,&b);
printf("\n\nBefore swapping %d %d\n\n",a,b);
a=a*b;
b=a/b;
a=a/b;
printf("After swapping %d %d",a,b);
getch();
}
out put : Enter two values: 1 2
Before swapping 1 2
After swapping 2 1
( OR )
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
clrscr();
printf("Enter two values:\n");
scanf("%d%d",&a,&b);
printf("\n\nBefore swapping %d %d\n\n",a,b);
a=a+b;
b=a-b;
a=a-b;
printf("After swapping %d %d",a,b);
getch();
}
out put : Enter two values: 1 2
Before swapping 1 2
After swapping 2 1
( OR )
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
clrscr();
printf("Enter two values:\n");
scanf("%d%d",&a,&b);
printf("\n\nBefore swapping %d %d\n\n",a,b);
b=(a+b)-(a=b);
printf("After swapping %d %d",a,b);
getch();
}
Before swapping 1 2
After swapping 2 1
( OR )
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
clrscr();
printf("Enter two values:\n");
scanf("%d%d",&a,&b);
printf("\n\nBefore swapping %d %d\n\n",a,b);
b=(a+b)-(a=b);
printf("After swapping %d %d",a,b);
getch();
}
out put : Enter two values: 1 2
Before swapping 1 2
After swapping 2 1
Before swapping 1 2
After swapping 2 1