Example of call by reference in C Program

C Programming Language >   Pointer in C Language >   Call by Reference in C  

Long Question

785


Answer:


 #include <stdio.h>  
void change(int*,int*);  
int main()  
{  
    int a=10,b=20;  
    change(&a,&b); // calling a function by passing references of variables.  
    printf("Value of a is: %d",a);  
    printf("\n");  
    printf("Value of b is: %d",b);  
    return 0;  
}  
void change(int *x,int *y)  
{  
    *x=13;  
    *y=17;  
}  

Output

Value of a is: 13
Value of b is: 17


This Particular section is dedicated to Question & Answer only. If you want learn more about C Programming Language. Then you can visit below links to get more depth on this subject.




Join Our telegram group to ask Questions

Click below button to join our groups.