0% found this document useful (0 votes)
4 views2 pages

Call by Value

The document explains two methods of function calling in C: call by value and call by reference. In call by value, the original values of variables remain unchanged as only copies are passed to the function, while in call by reference, the addresses of the variables are passed, allowing the original values to be altered. Example code snippets for both methods are provided to illustrate their differences.

Uploaded by

Suman Chatterjee
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

Call by Value

The document explains two methods of function calling in C: call by value and call by reference. In call by value, the original values of variables remain unchanged as only copies are passed to the function, while in call by reference, the addresses of the variables are passed, allowing the original values to be altered. Example code snippets for both methods are provided to illustrate their differences.

Uploaded by

Suman Chatterjee
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Function calling methods:

1. Call by value:

In case of call by value method we pass the value of variables inside a function during
invoking it.Here original value of the variables are not altered.All changes are performed
with dummy arguments.

#include<stdio.h>

#include<string.h>

void swap(int x, int y);

int main()

{int a,b;

printf("enter two numbers");

scanf("%d%d",&a,&b);

swap(a,b);

printf("\n%d%d",a,b);

return 0;

void swap(int x, int y)

int z;

z=x;

x=y;

y=z;

printf("\n%d%d",x,y);

2 Call by reference:

In case of call by reference method we pass the address of variables inside a function during
invoking it.Here original value of the variables are altered.

#include<stdio.h>
#include<string.h>

void swap(int *x, int *y);

int main()

{int a,b;

printf("enter two numbers");

scanf("%d%d",&a,&b);

swap(&a,&b);

printf("\n%d%d",a,b);

return 0;

void swap(int *x, int *y)

int z;

z=*x;

*x=*y;

*y=z;

printf("\n%d%d",*x,*y);

You might also like