OUTPUT (after running):
Enter any week day number: 4
You have entered THURSDAY.
We are in a position to write some programs now.
Example
1: Write a C program to show the concept of pass by value in C. Then rewrite that
same program using the concept of call by reference.
Solution 1:
Like any other arguments (data), array elements can also be passed by value and by
reference. In the pass by value method, the array elements are passed while in pass by reference
addresses of the array elements are passed. Let us write these two programs now.
/* using pass by value or call by value in C */
#include
#include
void main( )
{
int m [ ] = {10, 20, 30, 40 50}, i;
clrscr( );
for(i =0; i< 5; i++)
show(a[i]);
getch( );
}
show (int marks)
{
printf(“\t%d”, marks);
}
Do'stlaringiz bilan baham: |