Call by Value In
c language by default the arguments are passed to the function by
value. It means the actual arguments
copy their value into the formal arguments
. In call by value we can pass the value
.if any change is done into the
formal arguments it doesn't affect the actual arguments because both the arguments use the different memory
location .
Program
#include<stdio.h>
#include <conio.h>
void show ( int
a);
void main ()
{
Int x;
clrscr() ;
printf ( “enter the value
“);
scanf(“%d”,& x);
show (x);
printf( “\n now value of x
=%d” , x);
getch();
}
Void show ( int a )
{
a= a+1;
printf( “\n the value of a
=%d”, a);
}
Call by reference in this we can pass the address of a
variable in place of value .this means we can pass the address of actual
argument to the formal argument
#include<stdio.h>
#include <conio.h>
void show ( int
* a);
void main ()
{
Int x;
clrscr() ;
printf ( “enter the value
“);
scanf(“%d”,& x);
show ( &x);
printf( “\n now value of x
=%d” , x);
getch();
}
void show ( int *a )
{
*a=* a+1;
printf( “\n the value of a
=%d”, *a);
}
1 comments:
nice topic ....it is so simple
Post a Comment