Swaps values of two variables using a third variable in C Language

 WAP in C language that swaps values of two variables using a third variable.




#include<stdio.h>  

#include<conio.h>

 void main()    

{    

int a,b,temp;      

clrscr();

printf("\n Enter two values :");

scanf("%d%d",&a,&b);      

printf("\n Before swap a=%d b=%d",a,b);   

temp = a;

a = b;

b = temp;

printf("\n After swap a=%d b=%d",a,b);    

getch();

}   


Output

 Enter two values : 10  30

Before swap a=10   b=30

After   swap a=30    b=10


Post a Comment

0 Comments