Sunday, April 24, 2016

C program to swap two variables (Without using 3rd variable)

#include <stdio.h>
#include <conio.h>
void main()
{
int a,b,c;
clrscr();
printf("Enter the first number");
scanf("%d",&a);
printf("Enter the second number");
scanf("%d",&b);
a=a+b;
b=a-b;
a=a-b;
printf("The swapped numbers are \na=%d",a);
printf("\nb=%d",b);
getch();
}



That's it for now

Thank you for visiting

No comments:

Post a Comment