Demonstrate the call by Value and Call by Reference concept in function argument - C - A6P5



Write a program that Demonstrate the call by Value and Call by Reference concept in function argument 



#include<stdio.h>
#include<conio.h>
void val(int);
void ref(int *);
void main()
{
    int no;
    clrscr();
    printf("Enter Any Number -> ");
    scanf("%d",&no);
    printf("\nBefore Calling any Function -> %d ",no);
    val(no);
    printf("\nAfter Calling by Value      -> %d ",no);
    ref(&no);
    printf("\nAfter Calling by Reference  -> %d ",no);
    getch();
}
void val(int no)
{
    no=no+50;
}
void ref(int *p)
{
    *p+=50;
}

Post a Comment