Write a program to illustrate the call by value, Programming Languages

Assignment Help:

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.

 


Related Discussions:- Write a program to illustrate the call by value

Java source code classes and objects, Design and implement a stringed music...

Design and implement a stringed musical instrument class using the following guidelines: a. Data fields for your instrument should include number of strings, an array of stri

Draw a use case diagram in uml for order book, SailDublin Ferry provides fe...

SailDublin Ferry provides ferries to mainland Britain, Europe and America. Having observed the success of Irish ferries and Stennaline online booking system; SailDublin ferry has d

Windows card space, Windows Card Space Windows Card Space (codenamed Info C...

Windows Card Space Windows Card Space (codenamed Info Card), is Windows now-canceled customer application for the Identification Met system. Card Place is an instance of a class of

Shell script toconvert all lowercase to uppercase characters, Normal 0 ...

Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4

Example of undetermined coefficients, Example :  Solve the following differ...

Example :  Solve the following differential equation. y (3)   -  12 y''+48 y' + 64 y = 12 - 32 e -8t + 2 e 4t Solution :    We first require the complementary solution

Use an insertion sort to sort an array, Use an insertion sort to sort an ar...

Use an insertion sort to sort an array (sequence) of long word integers. The size of the list will appear just before the list itself. Use the same labels as in this example: LE

We need advancement in existing phonegap application, We need Advancement i...

We need Advancement in Existing PhoneGap Application We need a PhoneGap expert to aid us extend an existing PhoneGap application. The app works pulls data from a new website (de

Program for operate the rolodex, Program for Operate the Rolodex Rolod...

Program for Operate the Rolodex Rolodex is a rotating file, usually used to record business contact information. Cards are inserted in alphabetic order by name. You operate th

Matlab help, I am working on a matlab project and need help debugging one q...

I am working on a matlab project and need help debugging one question i have written and need help working through another problem.

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd