Friday, 24 January 2014

c program Swap 2 number without using third variable

 c program Swap 2 number without using third variable   

 #include <stdio.h>
    void main()
    {
    int a,b;
    printf("enter number1: ie a");
    scanf("%d",&a);
    printf("enter number2:ie b ");
    scanf("%d",&b);
    printf("value of a and b before swapping is \na=%d\nb=%d\n",a,b);
    a=a+b;
    b=a-b;
    a=a-b;
    printf("value of a and b after swapping is \na=%d\nb=%d\n",a,b);
    }

No comments:

Post a Comment