Sunday, 11 December 2011

Write a program to show function call by reference in c

#include
#include
void main()
{
int a;
a=200;
clrscr();
printf("\na = %d",a);
add(&a);
printf("\nAFTER RETURN FROM FUNCTION a=%d",a);
getch();
}
add(int*ptr)
{
*ptr = *ptr+200;
printf("\nIN FUNCTION a=%d",*ptr);
return;
}

OUTPUT
a = 200
IN FUNCTION a= 400
AFTER RETURN FROM FUNCTION a= 400

No comments:

Post a Comment