/* Program to swap two numbers */
#include<stdio.h>
#include<conio.h>
void main( )
{
float A,B;
printf("\n Enter the value of A ");
#include<stdio.h>
#include<conio.h>
void main( )
{
float A,B;
printf("\n Enter the value of A ");
scanf("%f ",&A);
printf("\n Enter the value of B ");
scanf("%f ",&B);
printf("\n Numbers before swapping are :- \n A=%f\nB=%f",A,B);
printf("\n Numbers before swapping are :- \n A=%f\nB=%f",A,B);
A=A+B;
B=A-B;
A=A-B;
B=A-B;
A=A-B;
printf("\n Numbers after swapping are :-");
printf("\n A=%f \nB=%f",A,B);
getch();
}
Output
Enter the value of A
30.0
printf("\n A=%f \nB=%f",A,B);
getch();
}
Output
Enter the value of A
30.0
Enter the value of B
90.0
Numbers before swapping are :-
A=30.000000
B=90.000000
Numbers after swapping are:-
A=90.000000
B=30.000000
Now the demonstration of the output is shown below: