Interchange or swaping of two values using comma operator :
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
clrscr();
a=10, b=20;
printf("a=%d and b=%d\n" ,a,b);
c=a, a=b, b=c;
printf(" /n");
printf(" After swaping :");
printf(" a=%d and b=%d\n" ,a,b);
getch();
}
Output:
Before swaping :
a=10 and b=20
After swaping :
a=20 and b=10
0 Response to "C Program: Swaping of two Numbers using Comma Operator"
Post a Comment