Showing posts with label swap. Show all posts
Program/code to swap two numbers in C language
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();
}
Saturday, 17 January 2015
Posted by Unknown