Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR C

swapping of two numbers in c without temporary variable

#include<stdio.h>  
void main()    
{    
int a=10, b=20;      
printf("Before swap a=%d b=%d",a,b);      
a=a+b;   
b=a-b;   
a=a-b;   
printf("
After swap a=%d b=%d",a,b);      
}   
 
PREVIOUS NEXT
Tagged: #swapping #numbers #temporary #variable
ADD COMMENT
Topic
Name
9+7 =