Ans:->
So,
What do you mean by Call by Refrence❓
➤
In Call by Refrence, the address of the variable is passed into the function call as the actual parameter and the origianal value of he variable is not modified.
The program to add two numbers using call by reference in C Language
Program is as follows:--
#include <stdio.h>
long addTwoNumbers(long *, long *);
int main()
{
long fno, sno, sum;
printf("\n\n Pointer : Add two numbers using call by reference:\n");
printf("-------------------------------------------------------\n");
printf(" Input the first number : ");
scanf("%ld", &fno);
printf(" Input the second number : ");
scanf("%ld", &sno);
sum = addTwoNumbers(&fno, &sno);
printf(" The sum of %ld and %ld is %ld\n\n", fno, sno, sum);
return 0;
}
long addTwoNumbers(long *n1, long *n2)
{
long sum;
sum = *n1 + *n2;
return sum;
}
OUTPUT:---
Pointer : Add two numbers using call by refrences:
-------------------------------------------------------------------------
Input the first number :500
Input the second number : 58
The sum of 500 and 58 is 558
THANKU FOR READING THIS ARTICLE ON-
If you want to suggest any changes in the program please feel free to contact us in the comment section or you can reach us using Contact us Page.
1 Comments
Much helpful
ReplyDeleteIf you want to give any suggestion regarding the post please feel free to Comment below-