write a program to illustrate the call by


Write a Program to illustrate the call by value?

#include .
int compute_sum(int m);
int main( void)
{
int n=3, sum;
printf("%d\n",n); /*3 is printed */
sum=compute_sum(n);
printf("%d\n",n); /*3 is printed */
printf("%d\n",sum); /*6 is printed */
return 0;
}

int compute_sum(int n) /*sum the integers from 1 to n*/ 9
{
int sum=0;
for (;n>O;--n) /*stored value of n is changed*/
sum+=n;
return sum;
}

Even although n is passed to compute_sum() and the value of n in the body of that function is changed the value of n in the calling environment remains unchanged It is the value of n that is being passed, not n itself.

 

Request for Solution File

Ask an Expert for Answer!!
Application Programming: write a program to illustrate the call by
Reference No:- TGS0304297

Expected delivery within 24 Hours