C program to Swap values of two Variables

Below is C program to Swap values of two Variables.

Program:

/*Swap the values of two Variables using three variables    */
#include<stdio.h>
int main()
{
 int a;
 int b;
 int c;

 printf("Type value of A : ");
 scanf("%i",&a);
 printf("\nType value of b : ");
 scanf("%i",&b);
 c=a;
 a=b;
 b=c;
 printf("A : %i",a);
 printf("\nb : %i",b);
 return 0;
}

No comments:

Post a Comment