Parameter Passing Techniques
Parameter Passing Techniques
NOTE: The changes made in the function are not transmitted back to the main
function . The moment the function definition encounters a ‘}’ the values created
in the function block are discarded , if the function consists of any return value it
should be written before ‘}’ , this return statement returns a value to the function in
main program.
Parameters are the values which are passed to the function .These can be passed in
two ways depending on the nature of the value sent.
#include<stdio.h>
void swapnum(int i, int j);
int main()
{
int a = 10, b = 20;
// passing parameters
swapnum(a, b);//func call
Output:
a is 10 and b is 20
Syntax
int var=10;
‘*’ represents the value at a address and “*ptr” represents the value at
address ptr
var=10
value 10 2008
#include<stdio.h>
void swapnum(int* i, int * j);
int main(void)
{
int a = 10, b = 20;
// passing parameters
swapnum(&a, &b);
Output:
a is 20 and b is 10