Q:

C Program For Swapping 2 Numbers Without Temp Variable

0

C Program For Swapping 2 Numbers Without Temp Variable

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

#include <stdio.h>
int main()
{
   int A, B;
 
   printf("Please enter the 1st number : ");
   scanf("%d",&A);
   printf("\nPlease enter the 2nd number : ");
   scanf("%d",&B);
 
   printf("\nBefore swapping:\n");
   printf("A - %d \nB - %d", A, B);
 
   A = A - B;
   B = A + B;
   A = B - A;
 
   printf("\nAfter swapping:\n");
   printf("A - %d \nB - %d", A, B);
 
   return 0;
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now