Pass by Value
In C and C++, parameters to a function are passed by value. This makes a copy of the variable and can be quite slow and inefficient if the variable is large like an array.
/*
http://www.ProbCOMP.com
In C and C++, parameters to a function are passed by value.
This makes a copy of the variable and can be quite slow and inefficient if the variable is large like an array.
*/
#include<stdio.h>
void swap(int a,int b)
{
int tmp;
tmp=a;
a=b;
b=tmp;
printf("a=%d and b=%d",a,b);
}
void main()
{
int a=10,b=20;
swap(a,b);
}
Download Program


