/* Without using any third varible*/
#include<stdio.h>
void SwapInCv(int x , int y) ; //function reference
void main()
{
int a,b ;
a=1 ;
a=1 ;
b=2 ;
SwapInC(a,b) ; //swap function call
printf("values after swaping a=%d & b=%d ", a , b) ;
} //End of main
void SwapInC(int x,int y) //definition
of Swap functon
{
y= x-y+(x=y);
}
Common Programming Error:-
C compiler read from left to right to do not confound with swap or switch logic.
Good Programming Practice:-
always use equation like i used instead using another temporary storage.
Common Programming Error:-
C compiler read from left to right to do not confound with swap or switch logic.
Good Programming Practice:-
always use equation like i used instead using another temporary storage.
No comments:
Post a Comment