C Program to Swap of two numbers without using third variable

Description

Get two integers a and b from user and swap the values without using third variable 
Sample Input 1:
6 5
Sample Output 1:
5 6

Solution

#include<stdio.h>

int main()

{
    
	int a,b,t;
	printf("Enter a:");
	scanf("%d",&a);
	printf("Enter b:");

	scanf("%d",&b);
	a=a+b;
	b=a-b;
	a=a-b;
	printf("\nAfter Swap\na: %d b: %d",a,b);  
	return 0;

}

Explanation

Get a and b using scanf statement

swap the values without using any extra variables.

Print a and b using printf statement



Interesting Pattern Programs: for more Patterns

Input:
5
Output:
*
**
***
****
*****
****
***
**
*Solution
Input:
5
Output:
    *
   ***
  *****
 *******
*********
 *******
  *****
   ***
    *Solution
Input:
5
Output:
*        *
**      **
***    ***
****  ****
**********Solution
Input:
5
Output:
*       *
**     **
***   ***
**** ****
*********Solution
Input:
5
Output:
*       *
**     **
***   ***
**** ****
*********
**** ****
***   ***
**     **
*       *Solution
Input:
5
Output:
*********
 *******
  *****
   ***
    *
   ***
  *****
 *******
*********Solution