Thursday 30 August 2012

Two numbers are input through the keyboard into two locations C and D. Write a program to interchange the contents of C and D.


main()
{
 int C,D;
 printf("Enter two numbers\n");
 scanf("%d%d",&C,&D);
 printf("C = %d\nD = %d\n",C,D);
 C=C+D; D=C-D; C=C-D;
 printf("After interchanging result is :-\n");
 printf("C = %d\nD = %d\n",C,D);
}

output:-

No comments:

Post a Comment