Total Pageviews

Program to accept two values of a & b and swap their values using temp/ addition/ multiplication


#include
#include
void main()
{
  int a,b,temp;
  clrscr();
  printf("Enter 1st number: ");
  scanf("%d",&a);
  printf("Enter 2nd number: ");
  scanf("%d",&b);
  printf("\nBefore Swapping..\n A=%d, B=%d",a,b);
  temp=a;                                               //a=a+b    or a=a*b
  a=b;                                                   //b=a-b    or b=a/b
  b=temp;                                                 //a=a-b    or a=a/b
  printf("\nAfter Swapping..\n A=%d, B=%d",a,b);
  getch();
}

No comments:

Post a Comment

Thank you