Thursday, 15 September 2011

How to swap two numbers in c

Swapping of two numbers using third variable.


#include<stdio.h>
#include<conio.h>
void main()
{
int a=10,b=20,c=0;
clrscr(); 
printf("a=%d \nb=%d",a,b); 
c=a;
a=b;
b=c;
printf("After swapping values of a & b are: \n "); 
printf("a=%d \nb=%d",a,b);
getch();


No comments:

Post a Comment