WAP to swap two numbers with the help of third variable

//WAP to interchange (swap) two numbers with the help of third variable//


#include<stdio.h>
#include<conio.h>
void main()
  int a, b, temp;
  printf("Enter the values\n");
  scanf("%d%d", &a, &b);
  printf("Numbers before swapping are:-  \na=%d\nb=%d", a, b);
   temp=a;
   a=b;
   b=temp;
  printf("Numbers after swapping are:-  \na=%d\nb=%d", a, b);
  getch();
}

  • The Input and Output of this program is shown in the pictures below:-                                                                                                                                                                                                                                                                     INPUT                                                                                                                                                      
                                                                                                                                                                                                                                                                                                                                                              OUTPUT                                                                                                                                       

Comments