My Tech notes: SWAP TWO NOS IN ONE STEP
Subscribe

Unix Documentation

Free Online Unix Training Materials

Lists many links to free Unix training materials.

Pointers and Arrays Materials

Pointers and Arrays materials Explained for C beginners

C FAQ and General Questions C Interview Questions

Powered By

Free XML Skins for Blogger

Powered by Blogger

Monday, June 2, 2008

SWAP TWO NOS IN ONE STEP

This is nice one..

int main()
{
int a,b;
printf("Enter two numbers\n");
scanf("%d%d",&a,&b);
printf("a=%d, b=%d\n",a,b);
b=a+b-(a=b);
printf("after swap a=%d b=%d\n",a,b);
return 0;
}

No comments:

Post a Comment