Problem Solving using C Language

0 of 77 lessons complete (0%)

Functions

Function Call by Reference

#include <stdio.h>

void func1(int *a){
    printf("\nIn func1 the value of a is: %d",*a);
}

void func2(int *a){
    printf("\nIn func2 the value of a is: %d",*a);
}

int main()
{
    int a=10, *p;
    p=&a;
    
    printf("In Func Main");
    func1(p);
    func2(p);
    func1(p);
    return 0;
}

Output is

In Func Main
In func1 the value of a is: 10
In func2 the value of a is: 10
In func1 the value of a is: 10[?2004h