/* program to understant the call by reference */
swapn( *num1, *num2 )
{
temp ;
temp = *num1 ;
*num1 = *num2 ;
*num2 = temp ;
}
main( )
{
n1 = 50, n2 = 30 ;
printf("Before swapping:");
printf("\nn1 is %d", n1);
printf("\nn2 is %d", n2);
/*calling swap function*/
swapn( &n1, &n2 );
printf("\n After swapping :");
printf("\n n1 is %d", n1);
printf("\n n2 is %d", n2);
0;
}
|