⚠ Switch to EXCALIDRAW VIEW in the MORE OPTIONS menu of this document. ⚠ You can decompress Drawing data with the command palette: ‘Decompress current Excalidraw file’. For more info check in plugin settings under ‘Saving’

Excalidraw Data

Text Elements

include <stdio.h>

void increment(int a){ a = a + 1; }

int main(){ int a;

    a = 10;
    
    increment(a);
    
    printf("Value of a = %d", a);
    
    return 0;

}

Calling function

called function

formal argument

actual argument

Call by Value

main: a

increment: a

is mapped to

Call by Value

Call by Reference

include <stdio.h>

void increment(int* p){ *p = (*p) + 1; }

int main(){ int a;

    a = 10;
    
    increment(&a);
    
    printf("Value of a = %d", a);
    
    return 0;

}

pass the address of a to increment

dereference the address to get value

Call by Reference

Address of main: a is shared with increment(), and increment() make changes in that address.