Program to show swap of two no's without using third variable

C Programming Language / Operators and Enums in C Language

948

Program:

/* Documentation Section
Program to show swap of two no's without using third variable
author: atnyla developer
*/

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b; 
	printf("enter value for a & b: ");
	scanf("%d%d",&a,&b);
	a=a+b;
	b=a-b;
	a=a-b;
	printf("after swapping the value of a & b: %d %d \n",a,b); 
}

Output:

enter value for a & b: 2 3
after swapping the value of a & b: 3 2
Press any key to continue . . .

Explanation:

  • The basic arithmetic operations in C Programming are addition, subtraction, multiplication, and division.
  • Arithmetic Operations are operated on Numeric Data Types as expected.
  • Arithmetic Operators are “Binary” Operators i.e they operate on two operands. These operators are used in mathematical expressions in the same way that they are used in algebra.

This Particular section is dedicated to Programs only. If you want learn more about C Programming Language. Then you can visit below links to get more depth on this subject.