C Program to swap two numbers without using third variable|E-studyblog2021|

 C Program to swap two numbers without using third variable|E-studyblog2021|


In this C-Program,we swap two numbers without using the third variable.We have done this Program by using  (+) and  (-).

     

C Program to swap two numbers without using third variable|E-studyblog2021|
 C Program to swap two numbers without using third variable|E-studyblog2021|


C Program to swap two numbers without using third variable|

// C program to swap the two numbers without using third variable
#include <stdio.h>
int main(){
	int a,b;
	printf("\nEnter the value of x & y\n");
	scanf("%d %d",&a,&b);
	printf("Before Swapping numbers :%d %d\n",a,b);
	 
	 a=a+b;
	 b=a-b;
	 a=a-b;
	 
	 printf("\nAfter Swapping: %d %d\n",a,b);
	 return 0;
}

Output:
C Program to swap two numbers without using third variable|E-studyblog2021|

I hope you have read our Article "C  Program to Swap the two numbers without using third variable|E-studyblog"  and  you have collected lots of information from there.If you like the post,then please comment and share among your friends and family. you can write your opinion about my post in the comment box. 


Thank you!

No comments:

Post a Comment

If you have any queries ,please let us know

C Program to Check whether the number is Even or Odd|how to find odd and even numbers in c programming|E-studyblog

I n this Article, you will learn how to   Check  whether the number is  Even or odd. We have shared the source code of odd and even number i...