Lec 16
Lec 16
int main() { b = a - b;
int x = 5, y = 10; a = a - b;
return 0; Output
Inside swap function: a = 10, b = 5
} After swap function: x = 5, y = 10
Completed so far…
Module 3: Functions: Introduction to Functions, Function Execution, Function
Prototyping and Definition, Parameter passing in functions (Call by Value, Call by
Reference), Recursion.
1025
1024
.
.
125
}
storing address of another variable
as value.
. …
0
What is pointer?
int roll_no = 125; P = 1024
}
address of another variable as value.
1026
Roll_no = 125
1025
Syntax: return_type *pointer_name;
1024
Int *p; (* : dereference operator) .
.
p = &roll_no; (&: Address of Operator) . …
0
// WAP to demonstrate pointer. Output
#include <stdio.h>
The roll no is 125
void main() { The address of roll no is
0x7ffe70c38c5c
int roll_no = 125; The address stored by ptr of roll no is
int *ptr = &roll_no; 0x7ffe70c38c5c
The value at address 0x7ffe70c38c5c
printf("The roll no is %d \n", roll_no); is 125
printf("The address of roll no is %p \n", &roll_no);
}
Parameter Passing: Call by Reference
❏ Pass the address while calling the defined
double power(double *x, int *n) {
functions.
❏ Example, power(&x, &n), where x is a double type if (*n == 0)
value and n is an integer value.
return 1;
return 0; Output
Inside swap function: a = 10, b = 5
} After swap function: x = 10, y = 5