Posts

Showing posts with the label 2nd sem Code

Call By Value And Call By Refrence

Call By Value #include <stdio.h> void swap( int , int ); void main() {    int a,b;       printf ( "enter the value of a and b " );    scanf ( "%d%d" ,&a,&b);    printf ( "before Swipe a=%d And b=%d" ,a,b);    swipe(a,b);    printf ( "\nafter swapping a=%d And b=%d" ,a,b); } void swipe( int a, int b) {    int temp;    temp=x;    x=y;    y=temp;    } Call By Reference #include <stdio.h> void swap( int *, int *); void main() {   int a,b;   printf ( "enter value of a and b" );   scanf ( "%d%d" ,&a,&b);   printf ( "before swap a=%d and b=%d" ,a,b);   swap(&a,&b);   printf ( "after swapping a=%d and b=%d" ,a,b);   } swap( int *x, int *y) {   int t;   t=*x;   *x=*y;   *y=t;   }