This C Program illustrates pass by reference. This program is used to explain how pass by reference function works.In pass by reference method, the function will operate on the original variable itself. It doesn’t work on a copy of the argument but works on the argument itself.
Here is source code of the C Program to illustrate pass by reference. The C program is successfully compiled and run on a Linux system. The program output is also shown below.
* C Program to Illustrate Pass by Reference
void cube( int *x);
int num = 10;
printf("the cube of the given number is %d", num);
void cube(int *x)
*x = (*x) * (*x) * (*x);
$ cc pgm49.c $ a.out Enter file name: pgm2.c There are 43 lines in pgm2.c in a file
Sanfoundry Global Education & Learning Series – 1000 C Programs.
If you wish to look at other example programs on Simple C Programs, go to Simple C Programs. If you wish to look at programming examples on all topics, go to C Programming Examples.