SWAPPING TO NUMBERS WITHOUT TAKING ANY TEMPORARY VARIABLE
/*We generally swap or interchange to variables by taking a temporary variable.Here is a simple program for swapping to numbers without using any intermediate variable*/
Language=C
#include<stdio.h>
int main()
{
int a,b;
printf( "Enter the value of a and b=" );
scanf( "%d%d",&a,&b );
printf( "a and b before swapping\n" );
printf( "%d %d\n",a,b );
a = a+b;
b = a-b;
a = a-b;
printf( "a and b after swapping\n" );
printf( "%d %d\n",a,b );
return 0;
}
Wednesday, 3 August 2016
Subscribe to:
Post Comments (Atom)
Kruskal Algorithm
Minimum Cost Spanning Tree By Kruskal Algorithm using priority_queue in c++ #include<bits/stdc++.h> using namespace std; typedef p...
-
SORTING A LINKED LIST /******************* linked list bubble sort complexity:O(n^2) *******************/ #include <bits/stdc++.h>...
-
OBJECT ORIENTED PROGRAMMING EXAMPLE Basic logic gates operations in C++ // there is a simple object oriented program that will read ...
-
STL:<stack> container For using stack container we have to include <stack> in our program.We already know that stack is last...
No comments:
Post a Comment