Sunday 6 October 2013

C program to swap two integer numbers without using third variable

#include<stdio.h>
#include<conio.h>
int main()
{
    float a,b;
    printf("enter the values to swap \n");
    scanf("%f%f",&a,&b);
    printf("before swapping a:%f b:%f\n",a,b);
    /*a=a+b;
    b=a-b;
    a=a-b;*/
    a=a*b;
    b=a/b;
    a=a/b;
    printf("After swapping a:%f b:%f\n",a,b);
    _getch();
    return 0;
}

No comments:

Post a Comment