PARAMETER PASSING METHOD :
parameter passing method is depending upon the values or pointing address are passed as an argument to a function. In this parameter passing method has two types.
1-------> call by value or Pass by value
2--------> call by Reference or Pass by reference
CALL BY VALUE:
The method of passing arguments by value is also known as call by value. In this method, the values of actual arguments are copied to the formal parameters of the function. Even though values of formal arguments are changed in the function it will not reflect back into calling / main program because we are giving only a copy of the actual argument values. Once the control returns back to the calling function the changes made in the called function will be disappeared.
|
#include<stdio.h> void swap(int x,int y); int main(){ int a, b; printf("enter the two values:\n"); scanf("%d\n%d",&a,&b); printf("before swapping function : a=%d b=%d \n ",a,b); swap(a,b); printf("after calling the swapping function : a=%d b=%d \n ",a,b); return 0; } void swap(int x,int y){ int temp; temp=x; x=y; y=temp; printf("value in swapping function: a=%d b=%d \n",x,y); } |
|
enter the two values: 4 6 before swapping function : a=4 b=6 value in swapping function: a=6 b=4 after calling the swapping function: a=4 b=6 |
| #include<stdio.h> void swap(int *x,int *y); int main(){ int a, b; printf("enter the two values:\n"); scanf("%d\n%d",&a,&b); printf("before swapping function : a=%d b=%d \n ",a,b); swap(&a,&b); printf("after calling the swapping function : a=%d b=%d \n ",a,b); return 0; } void swap(int *x,int *y){ int temp; temp=*x; *x=*y; * y=temp; printf("value in swapping function: a=%d b=%d \n",*x,*y); } |
| enter the two values: 5 8 before swapping function : a=4 b=6 value in swapping function: a=8 b=5 after calling the swapping function: a=8 b=5 |
LIBRARY FUNCTION OR BUILT-IN FUNCTION :
A predefined function is also called a library function or built-in functions. These functions are already written by the software provider. And all the functions are available in our system. We can only use the build-in functions on our program. we cannot do modify the function. these functions are grouped stored in library functions. Where we used this library function in our means, while we are starting the program first we have to insert some header files like #include<stdio.h>, #include<conio.h> these are the library functions, each library function having some build-in function, an example of the build-in functions are following,
|
function |
meaning |
example |
|
sqrt(x) |
square root |
sqrt(4) |
|
log(x) |
logarithm base 10 |
log(5) |
|
abs(x) |
absolute value of
integer |
abs(-20) |
|
fabs(x) |
absolute
values of float |
abs(-2.3) |
|
exp(x) |
ex exponentiation |
exp(5) |
|
pow(x,y) |
x raise to
the power y |
pow(4,6) |
|
ceil(x) |
rounding x to the next
smallest vlaues |
ceil(4.5) |
|
floor(x) |
rounding x to the next highest values |
floor(4.5) |
|
fmod(x,y) |
return the remainder
of x/y |
fmod(5,1) |
|
rand() |
generate
random integer |
rand() |
|
sin(x) |
find sin value |
sin(4) |
|
cos(x) |
find cosine value |
cos(5) |
|
tan(x) |
find tan value |
tan(5) |


No comments:
Post a Comment