48 C Program to Illustrate Pass by Reference
Posted by Superadmin on December 24 2015 02:14:56
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
*/
#include <stdio.h>
void cube( int *x);
int main()
{
int num = 10;
cube(&num);
printf("the cube of the given number is %d", num);
return 0;
}
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