Wednesday, 14 November 2012

PROGRAM TO SWAP TWO NUMBERS


1) USING THIRD VARIABLE


#include<stdio.h>
main()
{
int a,b,temp;
printf("Enter first number: ");
scanf("%d",&a);
printf("\nEnter second number: ");
scanf("%d",&b);
temp=a;
a=b;
b=temp;
printf("After swapping value of first and second is %d   %d",a,b);

}


OUTPUT:


Enter first number:  6

Enter second number:  8
After swapping value of first and second is 8  6