- Back to Home »
- C , code , coding , language , Numbers , program , project , project c++(basic) , swap »
- Program/code to swap two numbers in C language
Posted by : Unknown
Saturday, 17 January 2015
This code demonstrate the swaping of two numbers.
//program to swap two numbers input by user
#include<stdio.h>
#include<conio.h>
void main()
{
int x,y,a;
printf("Enter x:");
scanf("%d",&x);
printf("Enter y:");
scanf("%d",&y);
a=x;
x=y;
y=a;
printf("x is %d\n",x);
printf("y is %d",y);
getch();
}
//program to swap two numbers input by user
#include<stdio.h>
#include<conio.h>
void main()
{
int x,y,a;
printf("Enter x:");
scanf("%d",&x);
printf("Enter y:");
scanf("%d",&y);
a=x;
x=y;
y=a;
printf("x is %d\n",x);
printf("y is %d",y);
getch();
}