Swap two values without using third variable

Swap two values without using third variable

Welcome to the World of Online Learning:

Hello Friends “This blog helps you to learn C programming concepts. You can learn C language at your own speed and time. One can learn concepts of C language by practicing various programs given on various pages of this blog. Enjoy the power of Self-learning using the Internet.”

Swap two values without using third variable
Swap two values without using third variable

Write a C program to Swap two values without using third variable

/*    Swap the values of two variables without using third variable   */

#include<stdio.h>

int main()
{
 int a;
 int b;
 printf(“Type value of A : “);
 scanf(“%i”,&a);
 printf(“\nType value of b : “);
 scanf(“%i”,&b);
  a = a + b;
b = a – b;
a = a – b ;

 printf(“A : %i”,a);
 printf(“\nB : %i”,b);
 return 0;
}

Leave a Reply

Your email address will not be published. Required fields are marked *