Tuesday, 27 August 2013

c programe-pass by reference

#include<stdio.h>
#include<conio.h>

void fun1(int * , int *);

int main()
{
    int x=10,y=20;
   
    puts("before modeification");
    printf("x=%d\ny=%d",x,y);
    puts("...................................");
   
    fun1(&x,&y);
   
    printf("x=%d\ny=%d",x,y);
    getch();
    return 1;

}

void fun1(int *px,int *py)
{
     printf("px=%d\npy=%d",*px,*py);
    
     puts(".....................................");
     puts("after  modification");
    
     *px=100;
     *py=101;
    
     }
    

No comments:

Post a Comment