Monday, 21 May 2012

program to show function call by reference



113./*Write a program to show function call by reference*/

#include<stdio.h>
#include<conio.h>
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