Program to show swap of two no's without using third variable
C Programming Language Overview of C Language (Article) Overview of C Language (Program)
1429Program:
// Program to show swap of two no's without using third variable // Author Atnyla Developer #include #include 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:
Output 1 enter value for a & b: 2 3 after swapping the value of a & b: 3 2 Press any key to continue . . . Output 2 enter value for a & b: 12 56 after swapping the value of a & b: 56 12 Press any key to continue . . .
Explanation:
Program to show swap of two no's without using the third variable:
try this operation
try this operation
a = a+b;
b = a-b;
a = a-b;
<> 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.