Swap values of 2 variables using 3rd variable

Swap values of 2 variables using 3rd variable 

Program:

#include<stdio.h>
void main()
{
int m,n,w;
printf(“Enter numbers: ”);
scanf(“%d%d”,&m,&n);
printf("Values of numbers before swapping is: %d and %d\n”,m,n);
w=m;
m=n;
n=w;
printf("Values of numbers after swapping is: %d and %d\n”,m,n);
}
Output:


No comments:

Post a Comment