Users Online
· Guests Online: 148
· Members Online: 0
· Total Members: 188
· Newest Member: meenachowdary055
· Members Online: 0
· Total Members: 188
· Newest Member: meenachowdary055
Forum Threads
Newest Threads
No Threads created
Hottest Threads
No Threads created
Latest Articles
Articles Hierarchy
48 C Program to Illustrate Pass by Reference
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
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
Comments
No Comments have been Posted.
Post Comment
Please Login to Post a Comment.