Translate

Labels

Showing posts with label SWAPPING WITHOUT TEMP VARIABLE. Show all posts
Showing posts with label SWAPPING WITHOUT TEMP VARIABLE. Show all posts

Sunday, 15 February 2015

SWAPPING TWO NUMBERS IN A SINGLE STATEMENT

C program to swap two numbers in a single statement.



main()
{
int a=10,b=20;
c=(a+b)-(b=a);
printf("The numbers are :%d %d ",a,b);
getch();
}

Wednesday, 20 February 2013

SWAPPING WITH OUT TEMP VARIABLE


 int swap(int *a,int *b)
{
 *a=*a+*b;*b=*a-*b;*a=*a-*b;
}
main()
{
 int x=10,y=20;
 swap(&x,&y);
 printf("x= %d y = %d\n",x,y);
}