#include<stdio.h>
//pass the simple pointer to the function
void swapnum(int* i, int* j)
{
int tmp = *i;
*i = *j;
*j = temp;
}
int main()
{
int a = 10;
int b = 20;
swap(&a,&b);
printf("A is %d and B is %d
", a , b);
return 0;
}
#include <stdio.h>
void addOne(int* ptr) {
(*ptr)++; // adding 1 to *ptr
}
int main()
{
int* p, i = 10;
p = &i;
addOne(p);
printf("%d", *p); // 11
return 0;
}
#include <stdio.h>
void getDoubleValue(int *F){
*F = *F + 2;
printf("F(Formal Parameter) = %d
", *F);
}
int main(){
int A;
printf("Enter a numbers
");
scanf("%d", &A);
/* Calling function using call by reference */
getDoubleValue(&A);
/* Any change in the value of formal parameter(F)
will effect the value of actual parameter(A) */
printf("A(Actual Parameter) = %d
", A);
return 0;
}