Wednesday, July 20, 2011

Program to swap two numbers

/*Serial No.20     [swami99.cpp]*/

/* using third variable*/
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
clrscr();
printf("Enter the first no. a=");
scanf("%d",&a);
printf("Enter the second no. b=");
scanf("%d",&b);
c=a;
a=b;
b=c;
printf("\nAfter swap a=%d\tb=%d",a,b);
getch();
}

No comments:

Post a Comment

If you have any doubt, feel free to ask...