18. Program to Swap Two Numbers
//Using temporary variable::
void main()
{
int a,b,temp;
printf("enter two no");
scanf("%d%d",&a,&b);
temp=a;
a=b;
b=temp;
printf(" after swapping no a=%b",a,b);
getch();
}
void main()
{
int a,b,temp;
printf("enter two no");
scanf("%d%d",&a,&b);
temp=a;
a=b;
b=temp;
printf(" after swapping no a=%b",a,b);
getch();
}
/*Program to Swap Two Numbers*/
ReplyDelete#include
#include
void main()
{
int a,b,c;
clrscr();
printf("Enter value for A=");
scanf("%d",&a);
printf("Enter value for B=");
scanf("%d",&b);
c=a;
a=b;
b=c;
printf("Swapped Values of A=%d, B=%d",a,b);
getch();
}
#include
ReplyDelete#include
void main()
{
int a,b,temp;
printf("enter two no");
scanf("%d%d",&a,&b);
temp=a;
a=b;
b=temp;
printf(" after swapping no a=%b",a,b);
getch();
}
#include
ReplyDelete#include
void main()
{
int x,y,z;
clrscr();
printf("\nEnter the value of two numbers");
scanf("%d%d",&x,&y);
z=x;
x=y;
y=z;
printf("swapping no. are x is %d & y is %d",x,y);
getch();
}