Skip to main content

Call by reference example swap function

#include<stdio.h>
void swap(int *a,int *b)
{
int num;
num=*a;
*a=*b;
*b=num;
return;
}
int main()
{
int x=34,y=25;
printf("%d is %d\n",x,y);
swap(&x,&y);
printf("%d is %d \n",x,y);
return 0;
}

Comments

Popular posts from this blog

example of typecasting in c

/*Type Casting in C Typecasting allows us to convert one data type into other. */ //simple example to cast int value into the float. #include <stdio.h>    int   main (){   float   f = ( float ) 9 / 4 ;     printf ( "f : %f \n " ,  f  );     return   0 ;   }