Professional Documents
Culture Documents
Date
Page
10-Ses umbue
D
fUNCTION OINTER
Example-1
#incudesstdoh»
Mcunl)
int 1 0
funl),
w(u", fu); un adrus
pwntf ("ki"),
hi1345 3618
fu aderus
amlu -2
nclude Lstaio.hy
main)
int x10
h 13141886
31418H8b
NoTE
8fn, both wntte in brralf ) Mans
that t is adoles o the paiulan fnetion
Xam-5
inchae &Staio.hy
intf (void);_ Wawina Tmction
Maun) addros e doal Vadalde
int Z f ) ;
o Aen o_
brntf("ou", z)
itfou*z);
int tu(void) Adalre o_ Xwil
On Stack yaua wont
int 0;
Gwailable betaune Vatiabl dis
T
C
5Exam-5
inude <stäio.hz
int fun(void);
Man
int i, x
10 TYOY
o r 0 i5 i++) ddas ul
iiot xbi fnt times
printt(u hd,x
in
fun (vcid)
R
int 5
printtod
un (&),_
6) Exampl-6
inclule <stdio hy
ot fun (void);
Main)
int =10, *p
tor i=o, ik5;'i++)
tun)
btf (ou b. sp)
Poge
1Fxaml-7
#incude <stdie.b>
int fun(void)
Tnain
Int i, a 10, *p
to (i0, ia5;i++
prntf(u 7d Je",
int fu (veid) 6
int 5;
Addros 6
6
6
t i (ed", x);
aeiun 8X), 6
6
6
Addru
8 ineude sdo
int fn[void)
mo n)
inti 10, *
ov(ioia5,144)
int unvod)
8
8totie iot x: 5; dddro
X++
1
pratf("d ", x);
Seu (&)
Addrm 10 1
) orap-1
d e stdaoh
Stotic int x:5
int fun (void);
moi
int Oi
tun )
rwdf (" u Jdp *p);
clASSMAte
Dofe
Page
int *f(votd) 6
Addres e 6 6
Addre o7 7
tt
rutf(Jod ); 8
Addres 8 8
Addro o 1
0
Addre o
Exomple-10
#incude kstdo.hy
int x-5
int fun(void)
mainD
o Same a
int i 2-i0, PrDq TaM
funt)
prnt ( u dp.xp
int tum(veid)
brntf("d 2);
atun (3x))
C
E
poge
Examl-1
int fu C)
pnntf("h");
Chi
xample- a
int funveidl)
intF t ) ) D Weleome
ptr fns
fptr (
int nO
nntf ("ielco");
4 Example -H_
#include stdio.h>
Mai n )
f o tlo a,b);
printf"
Poge
5Exanla-5
incude kstdio hy
Recct awa (int, int);
manc) O6 T.5000o0
int lo, u: 5,
Hoat al
fRoat (kfptr)(int,int)
ptr-a
prntf Avesage =f a )
otetun(a+6)/a-o);
3
6 xampe-6
incuae<stduoh>
int add (int,int),
int Sub (int, int);
int mul int, int);
int uv (int, in+);
int adol inta,intb
uu(a+b);
Subint a,int b)
Sdusn a-b),
3
int (int a, int b)
Suetn (akb);
Suun (alb);
3
TMain)
Cane
fptr 8add;
pihtf("Sum d",a)
boak
Cae-
fptr 8sub,
a (Pper)();
rintf Dtn .d", a);
5SMAte
Date
Page
Cane *:
fptr 8mul
Cane
a (*fptr) (a»y)
prin tt (Divide %d a);
break
delutt:
prott( INvauo CHoICE!");
Examp-11
ncude 4stdlo.hy
intodd int,jiot)i
int Sub (int, int)z
int mul int, int),
int v (int, int ),
int add int a, int )
aun (atb);
slum (a -b);
int mulint a ,int b)
ndun (axb);
3
int dvlint a,intL)
stetuan(a/b);
3
main )
Cone +':
a-(*fp)(*y)
ntf Sum .d" a)j_
break,
Cane'-';
fptr2 Swo
a(*fptr:)*)3
pruti("Dikenu Jecd " a);
bveak;
ane x':
tptr3 mu
a (*fp 3) ( z«q)
print f ( Metltpu od ", a)5.
brreak
CAne / ' :
fpr dv;
a ( f p ) (.y)
printf ("diiede e oed", a);
breau
default:
ntt ( Invabel clhote {!!");
tion
MeavS eutte
So, wtion poin pameo as
ucteu
tion deiuitio is pome duotlon
Syntar:
ftion nction_beinky ot agamen b)
Etre declaution e futkon- bolnlan
hould be witn A
8 xon 18
tiotlude sStdo.hy
int add (int,iot);
int (* fp) (int , int);
int patn int (+)(iot,int) int ,int)
in t ad int a, intb)
int ye= +b
dsn(Ts)
jnt Main C)
l Sum- LO
ts/
int es a4b
etun (3ussa o);
marn )