c program to swap two numbers without using third variable
>> Tuesday, November 1, 2011
This is another important program to swap two numbers without using third variable. The bold letters indicated in this program
describe the concept of how swapping is made withou using any other variable. Below is the program which is implementing swaping of two numbers.
Output :
describe the concept of how swapping is made withou using any other variable. Below is the program which is implementing swaping of two numbers.
#include<stdio.h>
#include<conio.h>
int main()
{
int a,b,temp;
printf("enter two values\n");
printf("\na = ");
scanf("%d",&a);
printf("\tb = ");
scanf("%d",&b);
a=a+b; // swapping without using third variable
b=a-b;
a=a-b;
printf("\na = %d\tb = %d ", a, b);
getch();
}
Output :
0 comments:
Post a Comment