<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-7178346934090633966</id><updated>2024-09-01T08:37:43.533-07:00</updated><title type='text'>PASSING FUNCTION AS ARGUMENT IN C/C++</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://functionasargument.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7178346934090633966/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://functionasargument.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Sandeep</name><uri>http://www.blogger.com/profile/17751320119489927129</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>1</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-7178346934090633966.post-7731129225153459077</id><published>2012-09-23T23:29:00.001-07:00</published><updated>2013-08-06T01:47:06.550-07:00</updated><title type='text'>PASSING FUNCTION AS ARGUMENT IN C/C++</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;!--[if gte mso 9]&gt;&lt;xml&gt;
 &lt;o:OfficeDocumentSettings&gt;
  &lt;o:RelyOnVML/&gt;
  &lt;o:AllowPNG/&gt;
 &lt;/o:OfficeDocumentSettings&gt;
&lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;
 &lt;w:WordDocument&gt;
  &lt;w:View&gt;Normal&lt;/w:View&gt;
  &lt;w:Zoom&gt;0&lt;/w:Zoom&gt;
  &lt;w:PunctuationKerning/&gt;
  &lt;w:ValidateAgainstSchemas/&gt;
  &lt;w:SaveIfXMLInvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;
  &lt;w:IgnoreMixedContent&gt;false&lt;/w:IgnoreMixedContent&gt;
  &lt;w:AlwaysShowPlaceholderText&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;
  &lt;w:Compatibility&gt;
   &lt;w:BreakWrappedTables/&gt;
   &lt;w:SnapToGridInCell/&gt;
   &lt;w:WrapTextWithPunct/&gt;
   &lt;w:UseAsianBreakRules/&gt;
   &lt;w:DontGrowAutofit/&gt;
  &lt;/w:Compatibility&gt;
 &lt;/w:WordDocument&gt;
&lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;
 &lt;w:LatentStyles DefLockedState=&quot;false&quot; LatentStyleCount=&quot;156&quot;&gt;
 &lt;/w:LatentStyles&gt;
&lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 10]&gt;
&lt;style&gt;
 /* Style Definitions */
 table.MsoNormalTable
 {mso-style-name:&quot;Table Normal&quot;;
 mso-tstyle-rowband-size:0;
 mso-tstyle-colband-size:0;
 mso-style-noshow:yes;
 mso-style-parent:&quot;&quot;;
 mso-padding-alt:0in 5.4pt 0in 5.4pt;
 mso-para-margin:0in;
 mso-para-margin-bottom:.0001pt;
 mso-pagination:widow-orphan;
 font-size:10.0pt;
 font-family:&quot;Times New Roman&quot;;
 mso-ansi-language:#0400;
 mso-fareast-language:#0400;
 mso-bidi-language:#0400;}
&lt;/style&gt;
&lt;![endif]--&gt;

&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;PASSING FUNCTIONS AS ARGUMENT&lt;/b&gt;&lt;/div&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;DISCLAIMER&lt;/b&gt;: &lt;span style=&quot;font-size: 9pt; line-height: 115%;&quot;&gt;Though program(s) mentioned here is a
working program and also, I have tried my best to make this content error free,
but still I do not claim that every concept mentioned here is correct.
Therefore, content available here is not meant for primary source of learning.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;Introduction&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
We have passed variable, constants, structure variables to a
function as argument. But have you ever tried or thought to pass a &lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;function as an argument to another function&lt;/b&gt;.
If not, then let us do it together. At first sight it may appear a bit
confusing to you but trust me it is as simple as writing “int main()” .&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;Story behind this
story(blog): &lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Well, I want to share with you that how I thought to learn
this concept. Once I was programming a graphical Tic Tac Toe game in C++ using&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;a href=&quot;http://www.libsdl.org/&quot;&gt;SDL library&lt;/a&gt;,
in that I created 3 buttons to perform different actions like “New Game”,
”Exit”, ”High Score”. Therefore, it is obvious that these buttons will perform
different tasks, but for this I have to rewrite the same code 3 times to create
and display button that will perform its defined task. But, I was feeling too
lazy for that, so I thought that my work would get easier if I could somehow
pass function as an argument to a function, By doing this, I can simply write common
code for button just once and can pass different functions that perform their
defined tasks like start a new game, show high score etc. So, I searched on
Internet, got some hint, and completed my program.&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;Now let’s begin
Learning………….&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
I believe that you have some knowledge of pointers in C/C++.&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;REMEMBER&lt;/b&gt;:
FUNCTION NAME ACTUALLY REFERS TO THE ADDRESS OF THE FUNCTION.&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
If you had read and understood above line then you must have
guessed that we will need pointers to deal with memory addresses.&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
(We will see a complete working program later in this blog.)&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;ListParagraph&quot; style=&quot;mso-list: l0 level1 lfo1; text-indent: -.25in;&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;mso-bidi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;mso-list: Ignore;&quot;&gt;A.&lt;span style=&quot;font-size-adjust: none; font-stretch: normal; font: 7pt/normal &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;HOW
TO DECLARE POINTERS TO FUNCTION:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;text-indent: .5in;&quot;&gt;
&lt;b&gt;return_type (*pointer_name)(parameter_list);&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;text-indent: .5in;&quot;&gt;
Here, * tells that we declared a
pointer to function.&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;NOTE&lt;/b&gt;: If the function to be pointed does not take any arguments,
then you have to place &lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;()&lt;/b&gt; or &lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;(void)&lt;/b&gt; in place of parameter list.&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKkdrbcsItT0jn0cdXMVwNXjGSrFnqVYXveHbIPMoZtpfOBN7d_vmiGSCEbvwf5RG1i4O-G6bE6OdEuntwjfLIC1OiESnjsPdw1e6syqt_0OaEe6jE_1giI6rxrG-Fof5eKPbjXziG-PE/s1600/declare+function+pointer.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKkdrbcsItT0jn0cdXMVwNXjGSrFnqVYXveHbIPMoZtpfOBN7d_vmiGSCEbvwf5RG1i4O-G6bE6OdEuntwjfLIC1OiESnjsPdw1e6syqt_0OaEe6jE_1giI6rxrG-Fof5eKPbjXziG-PE/s1600/declare+function+pointer.PNG&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Declaration of Function&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;mso-no-proof: yes;&quot;&gt;
 
 
  
  
  
  
  
  
  
  
  
  
  
  
 
 
 

 
&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Above image clearly explains what these data types and names
means.&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;Please Note&lt;/b&gt;:
Parenthesis of &lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;(*compute)&lt;/b&gt; i.e. ‘&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;(‘&lt;/b&gt; and ‘&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;)’&lt;/b&gt; are compulsory(as per my knowledge) to remove ambiguity for
compiler, I mean If you do not enclose &lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;*compute&lt;/b&gt;
in parenthesis then compiler will get confused that &lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;*&lt;/b&gt; is used with void and your declaration will be treated as &lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;void * compute(int,int)&lt;/i&gt;, i.e.&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp; &lt;/span&gt;a function named compute taking two arguments
of int type and &lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;returning pointer of void
type&lt;/i&gt;.&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;Q.&lt;/b&gt; Create a
pointer for &lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;char sayHello(int,char) &lt;/b&gt;function.&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Ans. &lt;span style=&quot;color: #38761d;&quot;&gt;char &lt;/span&gt;(*fp)(&lt;span style=&quot;color: #38761d;&quot;&gt;int&lt;/span&gt;,&lt;span style=&quot;color: #38761d;&quot;&gt;char&lt;/span&gt;);&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;ListParagraph&quot; style=&quot;mso-list: l0 level1 lfo1; text-indent: -.25in;&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;mso-bidi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;mso-list: Ignore;&quot;&gt;B.&lt;span style=&quot;font-size-adjust: none; font-stretch: normal; font: 7pt/normal &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;INITIALIZING
FUNCTION POINTERS WITH A FUNCTION&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;ListParagraph&quot; style=&quot;mso-list: l0 level1 lfo1; text-indent: -.25in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;function_pointer_name=function_name;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;EXAMPLE&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/b&gt;Let a function sum:&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;mso-tab-count: 2;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #38761d;&quot;&gt;void
&lt;/span&gt;sum(&lt;span style=&quot;color: #38761d;&quot;&gt;int &lt;/span&gt;a, &lt;span style=&quot;color: #38761d;&quot;&gt;int &lt;/span&gt;b)&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;mso-tab-count: 2;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;mso-tab-count: 3;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;cout&amp;lt;&amp;lt;”Sum
=”&amp;lt;&amp;lt;a+b;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;mso-tab-count: 2;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt; &lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/b&gt;To initialize
compute(created earlier) we will write&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;mso-tab-count: 2;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;compute=sum;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;NOTE&lt;/b&gt;: do not use
parenthesis with sum( i.e do not write &lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;s&gt;sum()&lt;/s&gt;&lt;/b&gt;).&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;ListParagraph&quot; style=&quot;mso-list: l0 level1 lfo1; text-indent: -.25in;&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;mso-bidi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;mso-list: Ignore;&quot;&gt;C.&lt;span style=&quot;font-size-adjust: none; font-stretch: normal; font: 7pt/normal &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;CALLING
FUNCTIONS USING FUNCTION POINTERS&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;ListParagraph&quot; style=&quot;mso-list: l0 level1 lfo1; text-indent: -.25in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;function_pointer_name(arguments);&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;EXAMPLE&lt;/b&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;to call sum function using &lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;compute function pointer write&lt;/i&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;compute(5,2); &lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;or,
&lt;b&gt;compute(x,y);&lt;/b&gt; //where x,y may be a variable or a constant&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
See this(screen scrap of code):&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtocpEb3UCo7PPyC-paiv5kXkZEFcO2hEQdDj7l6KRz3S-8ZUajfLyCTsWw-_bEkXiNKtsxx1dXeSg7GSjvyXmSSKk8HsyRDYpVksHSOnV0xUqDPB0qZd46_MeoAiDKKjmnZUBWbkUXcM/s1600/initandcall.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtocpEb3UCo7PPyC-paiv5kXkZEFcO2hEQdDj7l6KRz3S-8ZUajfLyCTsWw-_bEkXiNKtsxx1dXeSg7GSjvyXmSSKk8HsyRDYpVksHSOnV0xUqDPB0qZd46_MeoAiDKKjmnZUBWbkUXcM/s1600/initandcall.PNG&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Calling Function&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;mso-no-proof: yes;&quot;&gt;
 
&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;ListParagraph&quot; style=&quot;mso-list: l0 level1 lfo1; text-indent: -.25in;&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;mso-bidi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;mso-list: Ignore;&quot;&gt;D.&lt;span style=&quot;font-size-adjust: none; font-stretch: normal; font: 7pt/normal &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;WRITING
FUNCTIONS THAT TAKE FUNCTION AS ARGUMENT&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;ListParagraph&quot; style=&quot;mso-list: l0 level1 lfo1; text-indent: -.25in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;u&gt;Functions taking functions as
argument&lt;/u&gt; are nothing but normal functions which contain one or more
pointers to function.&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhdUzJZpS7GM9KrBpzmT-N0lCxDBzPpjglqNWE5tYogmXproQwLbSsY-f2grx0WDFnTK187ycI_5SVbzZmWpz1fhO6usT0j3UfuUZMBqPTXwfneR9ZZAkZO6ysJNXZ-PC7B-NcYQqqZgdQ/s1600/ftf.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhdUzJZpS7GM9KrBpzmT-N0lCxDBzPpjglqNWE5tYogmXproQwLbSsY-f2grx0WDFnTK187ycI_5SVbzZmWpz1fhO6usT0j3UfuUZMBqPTXwfneR9ZZAkZO6ysJNXZ-PC7B-NcYQqqZgdQ/s1600/ftf.PNG&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Function that takes function as argument&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;EXAMPLE&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;mso-no-proof: yes;&quot;&gt;
 
&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
See that the function &lt;u&gt;takeFunction&lt;/u&gt;
is written in usual way except that there is a function pointer in its
parameter list (see &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;void (*fp) (int,int)
&lt;/span&gt;&lt;span style=&quot;mso-bidi-font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;above&lt;/span&gt;).&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
Please note that I have used two
more parameters &lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;a, b&lt;/i&gt; of &lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;int&lt;/i&gt; type that are used as arguments
while calling the function (see &lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;fp(a,b);&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;), &lt;/span&gt;&lt;span style=&quot;mso-bidi-font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;Its
was &lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;not mandatory to include int a, int
b&lt;/b&gt; in parameter list but still I included it for convenience. I might have
used the following definition which is also true, but you can see that each
time the function is called with same data (i.e. 5, 2) which is probably of no
use (see below).&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;color: #38761d;&quot;&gt;void
&lt;/span&gt;takeFunction(&lt;span style=&quot;color: #38761d;&quot;&gt;void &lt;/span&gt;(*fp) (&lt;span style=&quot;color: #38761d;&quot;&gt;int&lt;/span&gt;,&lt;span style=&quot;color: #38761d;&quot;&gt;int&lt;/span&gt;))// is not much reliable&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; f&lt;/span&gt;p(5,2);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;ListParagraphCxSpFirst&quot; style=&quot;mso-list: l0 level1 lfo1; text-indent: -.25in;&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;mso-bidi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;mso-list: Ignore;&quot;&gt;E.&lt;span style=&quot;font-size-adjust: none; font-stretch: normal; font: 7pt/normal &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;CALLING
FUNCTIONS THAT TAKE FUNCTION AS ARGUMENT&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;ListParagraphCxSpFirst&quot; style=&quot;mso-list: l0 level1 lfo1; text-indent: -.25in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;ListParagraphCxSpMiddle&quot;&gt;
Now, it’s time to call the function (ex. &lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;takeFunction&lt;/i&gt; defined above).&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;ListParagraphCxSpMiddle&quot;&gt;
See example below to understand&lt;/div&gt;
&lt;div class=&quot;ListParagraphCxSpMiddle&quot;&gt;
&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;takeFunction (sum, 5, 2);&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;ListParagraphCxSpLast&quot;&gt;
What I have done is just passed the &lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;sum function (defined in section B)&lt;/i&gt; to
this &lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;takeFunction&lt;/i&gt; function as
argument for its &lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;fp function pointer&lt;/i&gt;
, other arguments 5, 2 are passed in usual way as you do normally.&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;NOTE&lt;/b&gt;: do not use
parenthesis with sum( i.e &lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;s&gt;sum()&lt;/s&gt;&lt;/b&gt;)
when passing it as argument.&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;ListParagraphCxSpFirst&quot; style=&quot;mso-list: l0 level1 lfo1; text-indent: -.25in;&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;mso-bidi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;mso-list: Ignore;&quot;&gt;F.&lt;span style=&quot;font-size-adjust: none; font-stretch: normal; font: 7pt/normal &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;COMPLETE
C++ PROGRAM THAT USES ABOVE CONCEPTS&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;ListParagraphCxSpFirst&quot; style=&quot;mso-list: l0 level1 lfo1; text-indent: -.25in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;ListParagraphCxSpMiddle&quot; style=&quot;line-height: normal; mso-add-space: auto; mso-margin-bottom-alt: auto;&quot;&gt;
&lt;span style=&quot;color: #f9cb9c;&quot;&gt;&lt;span style=&quot;background-color: #666666;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;#i&lt;span style=&quot;background-color: #444444;&quot;&gt;&lt;/span&gt;nclude&amp;lt;iostream.h&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;ListParagraphCxSpMiddle&quot; style=&quot;line-height: normal; mso-add-space: auto; mso-margin-bottom-alt: auto;&quot;&gt;
&lt;span style=&quot;color: #f9cb9c;&quot;&gt;&lt;span style=&quot;background-color: #666666;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;#include&amp;lt;conio.h&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;ListParagraphCxSpMiddle&quot; style=&quot;line-height: normal; mso-add-space: auto; mso-margin-bottom-alt: auto;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;ListParagraphCxSpMiddle&quot; style=&quot;line-height: normal; mso-add-space: auto; mso-margin-bottom-alt: auto;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;color: #38761d;&quot;&gt;void &lt;/span&gt;sum(int
a, int b)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;ListParagraphCxSpMiddle&quot; style=&quot;line-height: normal; mso-add-space: auto; mso-margin-bottom-alt: auto;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;ListParagraphCxSpMiddle&quot; style=&quot;line-height: normal; mso-add-space: auto; mso-margin-bottom-alt: auto;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;cout&amp;lt;&amp;lt;&quot;\nSum =&quot;&amp;lt;&amp;lt;a+b;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;ListParagraphCxSpMiddle&quot; style=&quot;line-height: normal; mso-add-space: auto; mso-margin-bottom-alt: auto;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;ListParagraphCxSpMiddle&quot; style=&quot;line-height: normal; mso-add-space: auto; mso-margin-bottom-alt: auto;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;color: #38761d;&quot;&gt;void &lt;/span&gt;diff(int
a, int b)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;ListParagraphCxSpMiddle&quot; style=&quot;line-height: normal; mso-add-space: auto; mso-margin-bottom-alt: auto;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;ListParagraphCxSpMiddle&quot; style=&quot;line-height: normal; mso-add-space: auto; mso-margin-bottom-alt: auto;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;cout&amp;lt;&amp;lt;&quot;\nDifference
=&quot;&amp;lt;&amp;lt;a-b;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;ListParagraphCxSpMiddle&quot; style=&quot;line-height: normal; mso-add-space: auto; mso-margin-bottom-alt: auto;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;ListParagraphCxSpMiddle&quot; style=&quot;line-height: normal; mso-add-space: auto; mso-margin-bottom-alt: auto;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;ListParagraphCxSpMiddle&quot; style=&quot;line-height: normal; mso-add-space: auto; mso-margin-bottom-alt: auto;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;color: #38761d;&quot;&gt;void
&lt;/span&gt;takeFunction(void (*fp) (int,int),int a, int b)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;ListParagraphCxSpMiddle&quot; style=&quot;line-height: normal; mso-add-space: auto; mso-margin-bottom-alt: auto;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;ListParagraphCxSpMiddle&quot; style=&quot;line-height: normal; mso-add-space: auto; mso-margin-bottom-alt: auto;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;fp(a,b);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;ListParagraphCxSpMiddle&quot; style=&quot;line-height: normal; mso-add-space: auto; mso-margin-bottom-alt: auto;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;ListParagraphCxSpMiddle&quot; style=&quot;line-height: normal; mso-add-space: auto; mso-margin-bottom-alt: auto;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;ListParagraphCxSpMiddle&quot; style=&quot;line-height: normal; mso-add-space: auto; mso-margin-bottom-alt: auto;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;color: #38761d;&quot;&gt;int &lt;/span&gt;main()&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;ListParagraphCxSpMiddle&quot; style=&quot;line-height: normal; mso-add-space: auto; mso-margin-bottom-alt: auto;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;ListParagraphCxSpMiddle&quot; style=&quot;line-height: normal; mso-add-space: auto; mso-margin-bottom-alt: auto;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;clrscr();&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;ListParagraphCxSpMiddle&quot; style=&quot;line-height: normal; mso-add-space: auto; mso-margin-bottom-alt: auto;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #38761d;&quot;&gt;void &lt;/span&gt;(*compute)(int,int);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;ListParagraphCxSpMiddle&quot; style=&quot;line-height: normal; mso-add-space: auto; mso-margin-bottom-alt: auto;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;ListParagraphCxSpMiddle&quot; style=&quot;line-height: normal; mso-add-space: auto; mso-margin-bottom-alt: auto;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;compute=sum;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;ListParagraphCxSpMiddle&quot; style=&quot;line-height: normal; mso-add-space: auto; mso-margin-bottom-alt: auto;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;compute(5,2);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;ListParagraphCxSpMiddle&quot; style=&quot;line-height: normal; mso-add-space: auto; mso-margin-bottom-alt: auto;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;ListParagraphCxSpMiddle&quot; style=&quot;line-height: normal; mso-add-space: auto; mso-margin-bottom-alt: auto;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;compute=diff;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;ListParagraphCxSpMiddle&quot; style=&quot;line-height: normal; mso-add-space: auto; mso-margin-bottom-alt: auto;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;compute(5,2);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;ListParagraphCxSpMiddle&quot; style=&quot;line-height: normal; mso-add-space: auto; mso-margin-bottom-alt: auto;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;ListParagraphCxSpMiddle&quot; style=&quot;line-height: normal; mso-add-space: auto; mso-margin-bottom-alt: auto;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;takeFunction(sum,2,3);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;ListParagraphCxSpMiddle&quot; style=&quot;line-height: normal; mso-add-space: auto; mso-margin-bottom-alt: auto;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;takeFunction(diff,2,3);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;ListParagraphCxSpMiddle&quot; style=&quot;line-height: normal; mso-add-space: auto; mso-margin-bottom-alt: auto;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;ListParagraphCxSpMiddle&quot; style=&quot;line-height: normal; mso-add-space: auto; mso-margin-bottom-alt: auto;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;getch();&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;ListParagraphCxSpMiddle&quot; style=&quot;line-height: normal; mso-add-space: auto; mso-margin-bottom-alt: auto;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #134f5c;&quot;&gt;return &lt;/span&gt;0;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;ListParagraphCxSpMiddle&quot; style=&quot;line-height: normal; mso-add-space: auto; mso-margin-bottom-alt: auto;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;ListParagraphCxSpMiddle&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;ListParagraphCxSpMiddle&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;NO SEE
HOW DECLARATION OF VARIABLE POINTER IS DIFFERENT FROM FUCNTION POINTER&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;ListParagraphCxSpMiddle&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;mso-no-proof: yes;&quot;&gt;
 
&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;ListParagraphCxSpMiddle&quot;&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQ3dopJtSvX1quseRc0BWevvpPqbRzAGTNZWV0dwQUIhlOhrufn8EcO9xw_lWu2B1BbcEXyFR-HAda4v-bOAa5pxEPyD_4M1ofsxr-4NWUJ3MgULaSfNWnvLPywGTzeDsHAr5Ohey5N6U/s1600/lilchange.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQ3dopJtSvX1quseRc0BWevvpPqbRzAGTNZWV0dwQUIhlOhrufn8EcO9xw_lWu2B1BbcEXyFR-HAda4v-bOAa5pxEPyD_4M1ofsxr-4NWUJ3MgULaSfNWnvLPywGTzeDsHAr5Ohey5N6U/s1600/lilchange.PNG&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;see the difference&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQ3dopJtSvX1quseRc0BWevvpPqbRzAGTNZWV0dwQUIhlOhrufn8EcO9xw_lWu2B1BbcEXyFR-HAda4v-bOAa5pxEPyD_4M1ofsxr-4NWUJ3MgULaSfNWnvLPywGTzeDsHAr5Ohey5N6U/s1600/lilchange.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;br /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;ListParagraphCxSpLast&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;THANKS!!!!!!!!!!!!!!!!!&lt;/b&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://functionasargument.blogspot.com/feeds/7731129225153459077/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://functionasargument.blogspot.com/2012/09/passing-function-as-argument-in-cc.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7178346934090633966/posts/default/7731129225153459077'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7178346934090633966/posts/default/7731129225153459077'/><link rel='alternate' type='text/html' href='http://functionasargument.blogspot.com/2012/09/passing-function-as-argument-in-cc.html' title='PASSING FUNCTION AS ARGUMENT IN C/C++'/><author><name>Sandeep</name><uri>http://www.blogger.com/profile/17751320119489927129</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKkdrbcsItT0jn0cdXMVwNXjGSrFnqVYXveHbIPMoZtpfOBN7d_vmiGSCEbvwf5RG1i4O-G6bE6OdEuntwjfLIC1OiESnjsPdw1e6syqt_0OaEe6jE_1giI6rxrG-Fof5eKPbjXziG-PE/s72-c/declare+function+pointer.PNG" height="72" width="72"/><thr:total>0</thr:total></entry></feed>