Call by reference, C/C++ Programming

Assignment Help:

Call by reference:

Arguments to a function can be passed in two way; one by call by value and other by call

by reference.  Call by value is passed either through a constant or variable.  The call by reference is passed through address operator (&).  In C the function definition argument must be declared as pointer variable to pass by reference, where as in C++ the call by reference can be used without declaring the function arguments as pointer variables.  But in C++ both pointer argument method and without pointer argument can be adopted.

 

void f_ref(int &a, int &b); // void f_ref(int, int) is wrong for reference variable;

void main( )

{int a, b;

f_ref(a, b); // The value a is 10 and b is 20.

 

 

}

void f_ref(int &x, int &y)

{x =10;

y=20;

}


Related Discussions:- Call by reference

Pebble merchant problem, There is a pebble merchant. He sells the pebbles, ...

There is a pebble merchant. He sells the pebbles, that are used for shining the floor. His main duty is to take the length of the room’s sides. But he sometimes mistakes doing that

Determine the capacitor voltage by c program, Write a program to determine ...

Write a program to determine V c for a given value of time (t)   #include stdio.h #include math.h void main() {      char prompt;   float vs,cr,t,vc;   /* input time */

Working with files in cpp, Operation Files 2.1. Your program should open an...

Operation Files 2.1. Your program should open and read the file specified by the first command line argument of the program. 2.2. The first line of the file contains an integer

Explain register variable, Explain Register Variable Computers have int...

Explain Register Variable Computers have internal registers, which are used to keep data temporarily, before any operation can be performed. Intermediate results of the calcula

C program for maximum no, C Program for MAXIMUM NO, MINIMUM NO AND SORTING ...

C Program for MAXIMUM NO, MINIMUM NO AND SORTING   void main() {           int i,j,t;           int a[5];           clrscr();           for(i=0;i

#tit, Write a program to find the area under the curve y = f(x) between x =...

Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b. The area under a curve between two points can b

Program, Write a ‘C’ program to accept any 3 digit integer number from the ...

Write a ‘C’ program to accept any 3 digit integer number from the keyboard and display the word equivalent representation of the given number.

Program to design list in c, Program to design list in c: Write a prog...

Program to design list in c: Write a program in c to insert the values in list void main() { int i=0; char a[20]; clrscr(); printf("Enter the line\n");

Describe spaghetti programming, Describe spaghetti programming. - Spagh...

Describe spaghetti programming. - Spaghetti programming refers to codes which tend to get tangled and overlapped throughout the program. - It makes a program complex and ana

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