|
Hi,
As per question provided we have to use user defined function. So correct way could be as given by harishmitty using 3rd variable or as following
#include<stdio.h>
void main()
{
int M = 5, N = 3;
void swap (int m,int n);
printf("\nBefore Swap ");
printf("\n\tM=%d\tN=%d",M,N);
swap (M,N);
getch();
}
void swap(int m, int n)
{
m=m + n;
n = m - n;
m =m - n;
printf("\nAfter Swap ");
printf("\n\tm=%d\tn=%d",m,n);
}
__________________
Jyoti Bhatnagar
|