ProAnswers.org

WRITE A PROGRAMME TWO ENTER TWO NUMBERS AND SWAP TWO NUMBERS

#include
#include
void main()
{
int a,b; // a and b are integers
clrscr(); // this is a function that used to clear the previos output
printf(“enter any two numbres
“);
scanf(”%d%d”,&a,&b);
printf("value of First number before Swap = %d
",a);
printf("value of Second number before Swap = %d
",b);
/Logic to swap**********/
a =a+b; // sum of a+b given to a
b =a-b; // diffrence of a-b given to b;
a =a-b; // diffrence of a-b given to a;
printf("value of First number after Swap = %d
",a);
printf("value of Second number after Swap = %d
",b);

getch();
}