Tuesday, 10 January 2012

Swapping of 2 variables not using 3rd variable

#include<stdio.h>
#include<conio.h>

void main()
{
    int a=10,b=5;
    clrscr();
    printf("Initially  a=10 , b=5\n");
    a=a*b;
    b=a/b;
    a=a/b;
    printf("\nNow after swapping a and b is::\n");
    printf("a=%d , b=%d",a,b);
    getch();
}

No comments:

Post a Comment