Thursday, July 7, 2011

Swap programs:

swap program using 2 variables:

#include

#include

void main()

{

int a,b;

clrscr();

printf("enter the value for a");

scanf("%d",&a);

printf("enter the value for b");

scanf("%d",&b);

a=a+b;

b=a-b;

a=a-b;

printf("the swap values are %d\t%d\n",a,b);

getch();


}

Output:

enter the value for a4

enter the value for b2

the sorting values are 2 4


No comments:

Post a Comment