Example of call by reference in C Program

Long Answer
Views 701

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

Related Articles:

This section is dedicated exclusively to Questions & Answers. For an in-depth exploration of C Programming Language, click the links and dive deeper into this subject.

Join Our telegram group to ask Questions

Click below button to join our groups.