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...
-
Introduction: What is Computer Programming?This is the burning question for all who are interested in ...
-
SWAPPING TO NUMBERS WITHOUT TAKING ANY TEMPORARY VARIABLE /*We generally swap or interchange to variables by taking a temporary variabl...
-
Java:Sorting an array //This program will take some random values and sort them in ascending order import static java.lang.Math.abs; i...
No comments:
Post a Comment