C Program to Swap Two Numbers

 c program to swap two numbers without using third variable

Swap function in C

Swap function in C header file


----------------------------------------------------------------------------------------------------------------------#include<stdio.h>

#include<conio.h>

void main()

{  clrscr();

 int a,b;

 printf("enter two number to swap\n");

scanf("%d%d",&a,&b);


a=a+b;

b=a-b;

a=a-b;

 printf("swap number = %d,%d",a,b);

getch();}


-----------------------------------------------------------------------------------------------------------------------------


Comments

Popular Posts