<?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-5207350420173720706</id><updated>2026-03-09T08:42:29.467-04:00</updated><category term="C++"/><category term="C"/><category term="K+R"/><category term="cmath library"/><category term="sample code"/><category term="floating-point data type"/><category term="trig functions"/><category term="cstdio library"/><category term="cstdlib library"/><category term="functions"/><category term="integer data type"/><category term="log functions"/><category term="C++ ISO Standard"/><category term="Logic Operators"/><category term="VB6"/><category term="Windows 7"/><category term="abs function"/><category term="arrays"/><category term="if statement"/><category term="index"/><category term="math"/><category term="matrices"/><category term="8088"/><category term="Assembler"/><category term="Basic"/><category term="Cryptography"/><category term="Excel"/><category term="IBM PC"/><category term="ceil function"/><category term="char data type"/><category term="floor function"/><category term="hexadecimal"/><category term="history"/><category term="literals"/><category term="octals"/><title type='text'>Lessons In Coding</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://lessonsincoding.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5207350420173720706/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://lessonsincoding.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/5207350420173720706/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>James Piper</name><uri>http://www.blogger.com/profile/12387224587116087657</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGQ4ESUam_EJLtqp-f18iDIo2m7iCu_98TmJKP8if7vNZ76wasSEUxtnQLbxLqMcA2n9ozNH5PtbOy--l1i2r1znz7zBuCRwmXJOZCl1W_2WuKBPIJENOsjUnf27ltTw/s220/james_piper+sqr+image.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>71</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5207350420173720706.post-5409526796671748109</id><published>2012-04-05T13:50:00.000-04:00</published><updated>2012-04-08T16:19:20.512-04:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="functions"/><title type='text'>Passing An Array to Functions in C &amp; C++</title><content type='html'>&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:BrowserLevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&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 class=&quot;eNoIndent&quot;&gt;
The previous entry looked at various ways to pass a variable
to a function: by value, by reference or by pointer. This entry looks at
passing an array to a function. In C/C++ arrays are passed by reference or by
pointer, not by value. This means the called function can directly change the
array as passed by the caller. You can however pass one element of an array by
value in the same way you pass an integer or other data type.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
The
sample code calls a function, &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt;&quot;&gt;CapFirstLetter&lt;/span&gt;,
which takes a character array from the caller and raises the first letter of
each word to uppercase.&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
The
character array is created by:&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;char&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt; Text[] = &lt;span style=&quot;color: #a31515;&quot;&gt;&quot;Some
words to cap.&quot;&lt;/span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
I can
then define the function signature in one of two ways: with or without a
pointer.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt; CapFirstLetter(&lt;span style=&quot;color: blue;&quot;&gt;char&lt;/span&gt; vText[]);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt; CapFirstLetter(&lt;span style=&quot;color: blue;&quot;&gt;char&lt;/span&gt; * vText);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
The code inside the function is the same.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
I can then call the function in one of three ways:&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;CapFirstLetter(Text);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;CapFirstLetter(&amp;amp;Text[0]);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;char&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt; * pText =
&amp;amp;Text[0];&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;OR&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;char&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt; * pText = Text;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;CapFirstLetter(pText); &lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
The critical point to remember is that using the name of the
array, in this case, &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-size: 12.0pt;&quot;&gt;Text&lt;/span&gt;,
is actually a pointer to the first element of the array. Thus, using &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-size: 12.0pt;&quot;&gt;Text&lt;/span&gt; is the same as using &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-size: 12.0pt;&quot;&gt;&amp;amp;Text[0]&lt;/span&gt; and a pointer can
be assigned using either method. The result is the same.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;Sample Code.&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: green; font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;//
Standard I/O library.&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt; &lt;span style=&quot;color: #a31515;&quot;&gt;&amp;lt;cstdio&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: green; font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;//
Prototypes.&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt; CapFirstLetter(&lt;span style=&quot;color: blue;&quot;&gt;char&lt;/span&gt; vText[]);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt; CapFirstLetter2(&lt;span style=&quot;color: blue;&quot;&gt;char&lt;/span&gt; * vText);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt; main()&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;Call
Function To Cap First Letter of Every Word\n\n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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: green;&quot;&gt;/////////////////////////////////////////////////////////////////&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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: green;&quot;&gt;// 1. Pass array
by array name.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;1.
Pass array by array name.\n\n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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: blue;&quot;&gt;char&lt;/span&gt; Text[]
= &lt;span style=&quot;color: #a31515;&quot;&gt;&quot;Some words to cap.&quot;&lt;/span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;CapFirstLetter(Text);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;Version
1: %s\n&quot;&lt;/span&gt;, Text);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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: green;&quot;&gt;// The name of
the array is a pointer to first element.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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: blue;&quot;&gt;char&lt;/span&gt;
Text2[] = &lt;span style=&quot;color: #a31515;&quot;&gt;&quot; This&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;function&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;handles extra spaces.&quot;&lt;/span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;CapFirstLetter(&amp;amp;Text2[0]);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;Version
2: %s\n\n\n&quot;&lt;/span&gt;, Text2);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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: green;&quot;&gt;/////////////////////////////////////////////////////////////////&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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: green;&quot;&gt;// 2. Pass array
by pointer variable.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;2.
Pass array by pointer variable.\n\n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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: green;&quot;&gt;// Create
pointer.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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: blue;&quot;&gt;char&lt;/span&gt;
Text3[] = &lt;span style=&quot;color: #a31515;&quot;&gt;&quot;a statement with all lowercase
letters&quot;&lt;/span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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: green;&quot;&gt;// Option 1.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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: green;&quot;&gt;// The name of
the array, Text3, is a pointer to Text3[0].&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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: green;&quot;&gt;// char * pText =
Text3;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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: green;&quot;&gt;// Option 2.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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: green;&quot;&gt;// Another way to
get the address of the first element.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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: blue;&quot;&gt;char&lt;/span&gt; *
pText = &amp;amp;Text3[0];&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;CapFirstLetter(pText);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;Version
3: %s\n&quot;&lt;/span&gt;, Text3);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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: green;&quot;&gt;// Start later in
the array.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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: blue;&quot;&gt;char&lt;/span&gt;
Text4[] = &lt;span style=&quot;color: #a31515;&quot;&gt;&quot;a statement with all lowercase
letters&quot;&lt;/span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;pText = &amp;amp;Text4[2];&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;CapFirstLetter(pText);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;Version
4: %s\n&quot;&lt;/span&gt;, Text4);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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: green;&quot;&gt;// Close the
file.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;fclose(stdout);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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: green;&quot;&gt;// Return
something.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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: blue;&quot;&gt;return&lt;/span&gt; 0;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt; CapFirstLetter(&lt;span style=&quot;color: blue;&quot;&gt;char&lt;/span&gt; vText[])&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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: green;&quot;&gt;/////////////////////////////////////////////////////////////////&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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: green;&quot;&gt;// Capitalize
first letter of a string of text.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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: blue;&quot;&gt;short&lt;/span&gt; i;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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: blue;&quot;&gt;bool&lt;/span&gt;
PrevSpace = &lt;span style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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: blue;&quot;&gt;for&lt;/span&gt; (i = 0;
vText[i]; i++)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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; &lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;// Look to
find start of new word.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;if&lt;/span&gt;
(PrevSpace) &lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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; &lt;/span&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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; &lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;//
Ignore space.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;if&lt;/span&gt;
(vText[i] == &lt;span style=&quot;color: #a31515;&quot;&gt;&#39; &#39;&lt;/span&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;&lt;span style=&quot;mso-tab-count: 4;&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; &lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;//
Go to next char.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;&lt;span style=&quot;mso-tab-count: 4;&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; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;continue&lt;/span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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; &lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;// Not
a space, reset flag.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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; &lt;/span&gt;PrevSpace = &lt;span style=&quot;color: blue;&quot;&gt;false&lt;/span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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; &lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;//
Want lowercase only.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;if&lt;/span&gt;
((vText[i] &amp;gt;= 97) &amp;amp;&amp;amp; (vText[i] &amp;lt;= 122))&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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; &lt;/span&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;&lt;span style=&quot;mso-tab-count: 4;&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; &lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;//
Appy uppercase.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;&lt;span style=&quot;mso-tab-count: 4;&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; &lt;/span&gt;vText[i] -= 32;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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; &lt;/span&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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; &lt;/span&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;else&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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; &lt;/span&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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; &lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;//
Start of new word.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;if&lt;/span&gt;
(vText[i] == &lt;span style=&quot;color: #a31515;&quot;&gt;&#39; &#39;&lt;/span&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;&lt;span style=&quot;mso-tab-count: 4;&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; &lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;//
Reset.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;&lt;span style=&quot;mso-tab-count: 4;&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; &lt;/span&gt;PrevSpace = &lt;span style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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; &lt;/span&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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: green;&quot;&gt;// Return
success.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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: blue;&quot;&gt;return&lt;/span&gt; 0;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;Output.&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&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/AVvXsEgLYvY_whX8DZ5icK8btHt5y6oPELeKKxho8u93Heg-Db7FVv6UlOZeCcNYGmB67rOY7Bakz00QlcW8CemnNFMn3Qs5FqdY2H9CXT93GooRWpUyNxbgECDTeJvX7wI2I3BEIiRwWZOAlIU/s1600/2012.04.05+-+LessonsInCoding+-+Passing+An+Array+to+Functions+in+C+%2526+C%252B%252B.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;203&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgLYvY_whX8DZ5icK8btHt5y6oPELeKKxho8u93Heg-Db7FVv6UlOZeCcNYGmB67rOY7Bakz00QlcW8CemnNFMn3Qs5FqdY2H9CXT93GooRWpUyNxbgECDTeJvX7wI2I3BEIiRwWZOAlIU/s400/2012.04.05+-+LessonsInCoding+-+Passing+An+Array+to+Functions+in+C+%2526+C%252B%252B.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lessonsincoding.blogspot.com/feeds/5409526796671748109/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://lessonsincoding.blogspot.com/2012/04/passing-array-to-functions-in-c-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5207350420173720706/posts/default/5409526796671748109'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5207350420173720706/posts/default/5409526796671748109'/><link rel='alternate' type='text/html' href='http://lessonsincoding.blogspot.com/2012/04/passing-array-to-functions-in-c-c.html' title='Passing An Array to Functions in C &amp; C++'/><author><name>James Piper</name><uri>http://www.blogger.com/profile/12387224587116087657</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGQ4ESUam_EJLtqp-f18iDIo2m7iCu_98TmJKP8if7vNZ76wasSEUxtnQLbxLqMcA2n9ozNH5PtbOy--l1i2r1znz7zBuCRwmXJOZCl1W_2WuKBPIJENOsjUnf27ltTw/s220/james_piper+sqr+image.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgLYvY_whX8DZ5icK8btHt5y6oPELeKKxho8u93Heg-Db7FVv6UlOZeCcNYGmB67rOY7Bakz00QlcW8CemnNFMn3Qs5FqdY2H9CXT93GooRWpUyNxbgECDTeJvX7wI2I3BEIiRwWZOAlIU/s72-c/2012.04.05+-+LessonsInCoding+-+Passing+An+Array+to+Functions+in+C+%2526+C%252B%252B.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5207350420173720706.post-3577116372153165874</id><published>2012-04-04T11:04:00.000-04:00</published><updated>2012-04-08T13:20:29.960-04:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="functions"/><title type='text'>Passing Data to Functions in C &amp; C++</title><content type='html'>&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:BrowserLevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&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 class=&quot;eNoIndent&quot;&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:BrowserLevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&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;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
C and C++ are built on functions. All programs in C/C++
start with a &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;main()&lt;/span&gt; function and
branch out from there to other functions. Generally, since it&#39;s considered poor
coding practice to use global variables, you will need a way to pass local
variables from one function to another. This blog looks at the different way of
passing data to a function.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;1. Pass By Value.&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
The default in C/C++ is to pass the value of a variable to a
function. This means the function cannot change the value of the variable in
the caller function. Here is some test code to show this point.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt; i = 10;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;Pass Argument by Value.\n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;Value before function call: %d.\n&quot;&lt;/span&gt;, i);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;ByVal(i);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;Value after function call: %d.\n&quot;&lt;/span&gt;, i);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt; ByVal(&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; Parameter)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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: green;&quot;&gt;// Change won&#39;t
happen.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Parameter = 100;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;Value
in function: %d.\n&quot;&lt;/span&gt;, Parameter);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;gt;Pass Argument by
Value.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;gt;Value before
function call: 10.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;gt;Value in
function: 100.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;gt;Value after
function call: 10.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&amp;nbsp; &lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
When a variable is passed to a function by value, the
language copies the value to the heap—the dynamic runtime memory. The variable
in the caller function is thus duplicated—one copy in the caller function and one
copy for the called function. This is not an efficient use of
resources. It uses up memory and it takes time to copy the data. A better way
is to pass a memory address of the variable to the called function.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;2. Pass By Reference.&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
If I declare &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;MyVar&lt;/span&gt;
as integer type, I can find out its memory address with the &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;amp;&lt;/span&gt; operator. The first method of
passing a memory address to a variable uses this operator. I define the
function with a parameter of &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;DataType &amp;amp;VariableName&lt;/span&gt;.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;i = 20;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;\nPass Argument by Reference.\n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;Value before function call: %d.\n&quot;&lt;/span&gt;, i);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;Address of i in main: %#X.\n&quot;&lt;/span&gt;, &amp;amp;i);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;ByRef(i);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;Value after function call: %d.\n&quot;&lt;/span&gt;, i);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt; ByRef(&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; &amp;amp;Parameter)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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: green;&quot;&gt;// Value changes.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Parameter = 200;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;Value
in function: %d.\n&quot;&lt;/span&gt;, Parameter);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;Address
of Parameter in function: %#X.\n&quot;&lt;/span&gt;, &amp;amp;Parameter);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;gt;Pass Argument by
Reference.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;gt;Value before
function call: 20.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;gt;Address of i in
main: 0X36EB8C.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;gt;Value in fn: 200.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;gt;Address of
Parameter in function: 0X36EB8C.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;gt;Value after
function call: 200.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
Because the function &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;ByRef&lt;/span&gt;
function has direct reference to the &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;i&lt;/span&gt;
variable, it can change the value. You will note the memory address is the same
inside the function as it is in the caller function.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;3. Pass By Pointer.&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
The previous example indirectly passed the memory address
for the parameter with &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;ByRef(i)&lt;/span&gt;
instead of &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;ByRef(&amp;amp;i)&lt;/span&gt;. The
function used the &amp;amp; operator. In this example, the
caller must pass a pointer—a direct reference to the memory location. The end
result is the same.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;* pi = &amp;amp;i;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;i = 30;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;\nPass Argument by Pointer.\n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;Value before function call: %d.\n&quot;&lt;/span&gt;, i);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;Address of i in main: %#X.\n&quot;&lt;/span&gt;, pi);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;ByPointer(pi);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;Value after function call: %d.\n&quot;&lt;/span&gt;,
*pi);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt; ByPointer(&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt;* Parameter)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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: green;&quot;&gt;// Value changes.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;*Parameter = 300;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;Value
in function: %d.\n&quot;&lt;/span&gt;, *Parameter);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;Address
of Parameter in function: %#X.\n&quot;&lt;/span&gt;, Parameter);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;gt;Pass Argument by
Pointer.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;gt;Value before
function call: 30.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;gt;Address of i in
main: 0X36EB8C.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;gt;Value in fn:
300.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;gt;Address of
Parameter in function: 0X36EB8C.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;gt;Value after
function call: 300.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&amp;nbsp;&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:BrowserLevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&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;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
Calling the function with a pointer, &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;ByPointer(pi)&lt;/span&gt;, is equivalent to this: &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;ByPointer(&amp;amp;i)&lt;/span&gt;.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
These examples used the integer data type. The code could be
modified to use the other built-in data types: &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;char,
bool, double, float&lt;/span&gt;. For passing an array, especially a character array,
to a function, see the next blog entry.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lessonsincoding.blogspot.com/feeds/3577116372153165874/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://lessonsincoding.blogspot.com/2012/04/passing-data-to-functions-in-c-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5207350420173720706/posts/default/3577116372153165874'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5207350420173720706/posts/default/3577116372153165874'/><link rel='alternate' type='text/html' href='http://lessonsincoding.blogspot.com/2012/04/passing-data-to-functions-in-c-c.html' title='Passing Data to Functions in C &amp; C++'/><author><name>James Piper</name><uri>http://www.blogger.com/profile/12387224587116087657</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGQ4ESUam_EJLtqp-f18iDIo2m7iCu_98TmJKP8if7vNZ76wasSEUxtnQLbxLqMcA2n9ozNH5PtbOy--l1i2r1znz7zBuCRwmXJOZCl1W_2WuKBPIJENOsjUnf27ltTw/s220/james_piper+sqr+image.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5207350420173720706.post-4844265054997618309</id><published>2012-04-03T06:15:00.000-04:00</published><updated>2012-04-03T06:15:38.047-04:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C"/><category scheme="http://www.blogger.com/atom/ns#" term="C++"/><category scheme="http://www.blogger.com/atom/ns#" term="cstdio library"/><title type='text'>The freopen Functions in C &amp; C++</title><content type='html'>&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:BrowserLevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&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 class=&quot;eNoIndent&quot;&gt;
&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;The freopen &lt;/span&gt;Function.&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
The &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;freopen&lt;/span&gt; function
in the C Standard I/O library &amp;lt;cstdio&amp;gt; is a useful to redirect output destined
for the &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;stdout&lt;/span&gt; to a text file. I
discussed how to use the &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;fprintf&lt;/span&gt;
function to send output to either a text file or the &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;stdout&lt;/span&gt;. See &lt;a href=&quot;http://lessonsincoding.blogspot.ca/2012/03/using-stdin-stdout-in-c-c.html&quot;&gt;here&lt;/a&gt;.
The same result is achieved here using the &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;printf&lt;/span&gt;
and &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;freopen&lt;/span&gt; functions.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;Method 1.&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;freopen(Filename, &quot;w&quot;, stdout);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
There is no return value to indicate if the file was opened
or if there was an error.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;Method 2.&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;iReturn = freopen(Filename, &quot;w&quot;, stdout);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
On failure, a null pointer is returned otherwise the return
value is a pointer to the file. Beyond testing for an error, this return value
is used to close the file.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;fclose(iReturn);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
While my example uses the &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;stdout&lt;/span&gt;, the &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;freopen&lt;/span&gt;
function can be used with the &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;stdin&lt;/span&gt; and &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;stderr&lt;/span&gt;
objects.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&amp;nbsp;&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:BrowserLevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&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;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;Test Code.&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
I tested the functions in Visual C++ 2010 as an console
application.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: green; font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;// The
standard library includes the system function.&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt; &lt;span style=&quot;color: #a31515;&quot;&gt;&amp;lt;cstdlib&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: green; font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;// C++
standard I/O library.&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt; &lt;span style=&quot;color: #a31515;&quot;&gt;&amp;lt;cstdio&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt; main()&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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: green;&quot;&gt;//**************************************************************&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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: green;&quot;&gt;// Redirect
stdout to a file.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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: green;&quot;&gt;// Declare
pointer to the file.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;FILE* pFileHandle;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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: blue;&quot;&gt;char&lt;/span&gt;
Filename[] = &lt;span style=&quot;color: #a31515;&quot;&gt;&quot;MyFile.txt&quot;&lt;/span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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: green;&quot;&gt;// Returns null
is the open failed.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;pFileHandle = freopen(Filename, &lt;span style=&quot;color: #a31515;&quot;&gt;&quot;w&quot;&lt;/span&gt;, stdout);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;pFileHandle
is %X.\n\n&quot;&lt;/span&gt;, pFileHandle);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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: green;&quot;&gt;//**************************************************************&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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: green;&quot;&gt;// Header.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;Using
freopen in C &amp;amp; C++\n\n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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: green;&quot;&gt;//**************************************************************&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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: green;&quot;&gt;// Some use of
printf.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;Sending
the printf output to a file instead of the stdout.\n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;The
freopen function allows for this redirection.\n\n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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: green;&quot;&gt;// Use variable
for a string.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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: blue;&quot;&gt;char&lt;/span&gt; * Text
= &lt;span style=&quot;color: #a31515;&quot;&gt;&quot;A text string only from a
variable.\n\n&quot;&lt;/span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;%s&quot;&lt;/span&gt;,
Text);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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: green;&quot;&gt;// Int type.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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: blue;&quot;&gt;int&lt;/span&gt; Salary
= 375000;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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: blue;&quot;&gt;int&lt;/span&gt; Bonus =
-35000;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;Salary
is: %8d.\n&quot;&lt;/span&gt;, Salary);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;Bonus&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp; &lt;/span&gt;is: %8d.\n&quot;&lt;/span&gt;, Bonus);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;\n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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: green;&quot;&gt;//**************************************************************&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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: green;&quot;&gt;// Close the
file.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;fclose(pFileHandle);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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: green;&quot;&gt;// Keep console
window open.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;system(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;pause&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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: green;&quot;&gt;// Return some
value.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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: blue;&quot;&gt;return&lt;/span&gt; 0;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;} &lt;span style=&quot;color: green;&quot;&gt;// end main&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&amp;nbsp;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;Output.&lt;/b&gt;&lt;/div&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/AVvXsEjIsitPlyVJfs3P1_DvDbAcurwilI0TpCJCJfNvUPmA2tQZ1IOdZJHC9qHsI9dz4fNODUzoLx-f4ykfBo3hN41wEzvyK6egtP_J3FxISrqCnNo_hGjCXcBq3berATgeE_Y5WLoRuSdgBDA/s1600/2012.04.02+-+LessonsInCoding+-+The+freopen+Functions+in+C+&amp;amp;+C++.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;271&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIsitPlyVJfs3P1_DvDbAcurwilI0TpCJCJfNvUPmA2tQZ1IOdZJHC9qHsI9dz4fNODUzoLx-f4ykfBo3hN41wEzvyK6egtP_J3FxISrqCnNo_hGjCXcBq3berATgeE_Y5WLoRuSdgBDA/s400/2012.04.02+-+LessonsInCoding+-+The+freopen+Functions+in+C+&amp;amp;+C++.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lessonsincoding.blogspot.com/feeds/4844265054997618309/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://lessonsincoding.blogspot.com/2012/04/freopen-functions-in-c-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5207350420173720706/posts/default/4844265054997618309'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5207350420173720706/posts/default/4844265054997618309'/><link rel='alternate' type='text/html' href='http://lessonsincoding.blogspot.com/2012/04/freopen-functions-in-c-c.html' title='The freopen Functions in C &amp; C++'/><author><name>James Piper</name><uri>http://www.blogger.com/profile/12387224587116087657</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGQ4ESUam_EJLtqp-f18iDIo2m7iCu_98TmJKP8if7vNZ76wasSEUxtnQLbxLqMcA2n9ozNH5PtbOy--l1i2r1znz7zBuCRwmXJOZCl1W_2WuKBPIJENOsjUnf27ltTw/s220/james_piper+sqr+image.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIsitPlyVJfs3P1_DvDbAcurwilI0TpCJCJfNvUPmA2tQZ1IOdZJHC9qHsI9dz4fNODUzoLx-f4ykfBo3hN41wEzvyK6egtP_J3FxISrqCnNo_hGjCXcBq3berATgeE_Y5WLoRuSdgBDA/s72-c/2012.04.02+-+LessonsInCoding+-+The+freopen+Functions+in+C+&amp;+C++.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5207350420173720706.post-7497861264315431966</id><published>2012-04-02T09:36:00.000-04:00</published><updated>2012-04-07T09:49:05.113-04:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C"/><category scheme="http://www.blogger.com/atom/ns#" term="C++"/><title type='text'>The printf Function in C &amp; C++</title><content type='html'>&lt;br /&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&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;The printf&lt;/span&gt; Function.&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
The &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;printf&lt;/span&gt;
function in the C Standard I/O library &amp;lt;cstdio&amp;gt; is a useful and versatile
way to send output to the &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;stdout&lt;/span&gt;.
Your output is a string that may include formatted variable values. The most
basic form doesn&#39;t use any variables, such as:&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;printf(&quot;This
output is a text string only. No variables.\n&quot;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&amp;gt;This
output is a text string only. No variable.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
The next step is to include a variable as part of the
output. For example,&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;char * Text =
&quot;A text string only from a variable.\n&quot;;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;printf(&quot;%s&quot;,
Text);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&amp;gt;A text
string only from a variable.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
The code &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;%s&lt;/span&gt;
is a format specifier for a character array or string. The &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;%s&lt;/span&gt; is replaced by the value of &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;Text&lt;/span&gt;. This principle applies to
other data types. A decimal integer uses &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;%d
or %i&lt;/span&gt;.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;int Salary =
375000;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;printf(&quot;Salary
is: %d.\n&quot;, Salary);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;printf(&quot;Salary
is: %i.\n&quot;, Salary);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&amp;gt;Salary
is: 375000.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&amp;gt;Salary
is: 375000.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
The definition of the specifier is:&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;%[flags][width][.precision][length]specifier
&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
The square brackets means the parameter is optional. Hence,
the most basic specifier is % followed by a letter of: c, d, i, e, E, f, g, G,
o, s, u, x, X, p, or n.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
This blog will go through examples of these specifiers and
the various parameters. Once you understand the &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;printf&lt;/span&gt;
function, you can apply this knowledge in using the &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;fprintf,&lt;/span&gt; f&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;scanf,&lt;/span&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;scanf, sprintf, sscanf&lt;/span&gt;
functions.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;Integer Data Types.&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
There are three specifiers for the integer data type in
decimal format (Base 10). &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;%d&lt;/span&gt;
and &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;%i&lt;/span&gt; apply to signed integers. &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;%u&lt;/span&gt; applies to unsigned integers.
If you use &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;%u&lt;/span&gt; with a signed
integer, the output will be garbage.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;Salary =
-35000;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;printf(&quot;Using
it with a negative value: %u doesn&#39;t work.\n\n&quot;, Salary);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&amp;gt;Using it
with a negative value: 4294932296 doesn&#39;t work.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
You can use an unsigned integer with %d or %i.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;unsigned
ActNum = 1234;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;printf(&quot;Unsigned
variable works with %%i or %%d. ActNum is %i.\n\n&quot;, ActNum);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&amp;gt;Unsigned variable
works with %i or %d. ActNum is 1234.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;Width.&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
You specify the width the value takes up by adding a number such as &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;%8d&lt;/span&gt; or
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;%8i&lt;/span&gt;. Setting a width allows you
to align numbers.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;int Salary =
12345678;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;int Bonus =
52000;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;printf(&quot;Salary
is: %8d.\n&quot;, Salary);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;printf(&quot;Bonus&amp;nbsp; is: %8d.\n&quot;, Bonus);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&amp;gt;Salary
is: 12345678.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&amp;gt;Bonus&amp;nbsp; is:&amp;nbsp;&amp;nbsp;&amp;nbsp;
52000.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
If the number is larger than the width, the amount will be
displayed, but the alignment will be askew.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;int Salary =
1234567890;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;int Bonus =
52000;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;printf(&quot;Salary
is: %8d.\n&quot;, Salary);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;printf(&quot;Bonus&amp;nbsp; is: %8d.\n&quot;, Bonus);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&amp;gt;Salary
is: 1234567890.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&amp;gt;Bonus&amp;nbsp; is:&amp;nbsp;&amp;nbsp;&amp;nbsp;
52000.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;Alignment.&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
The default is to align numbers to the right. You can add a
minus sign such as %-8d to specify left alignment.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;printf(&quot;Salary
is: %-8d.\n&quot;, Salary);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;printf(&quot;Bonus&amp;nbsp; is: %-8d.\n\n&quot;, Bonus);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&amp;gt;Salary
is: 375000&amp;nbsp; .&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&amp;gt;Bonus&amp;nbsp; is: 52000&amp;nbsp;&amp;nbsp;
.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;b&gt;Decimal. Hexadecimal. Octal.&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
To output a hexadecimal numbers use %x (lowercase) or &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;%X&lt;/span&gt; (uppercase). An octal can be
outputted with &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;%o&lt;/span&gt;.
It&#39;s the lowercase letter o for octal, not zero. See more examples &lt;a href=&quot;http://lessonsincoding.blogspot.ca/2012/03/numbering-notations-in-c-c.html&quot;&gt;here&lt;/a&gt;.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;int num = 65535;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;printf(&quot;Decimal: %d Hexadecimal:
%X Octal: %o \n&quot;, num, num, num);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;printf(&quot;Hexadecimal Uppercase: %X
Lowercase: %x \n&quot;, num, num);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&amp;gt;Decimal: 65535 Hexadecimal: FFFF
Octal: 177777 &lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&amp;gt;Hexadecimal Uppercase: FFFF
Lowercase: ffff&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
Use &#39;#&#39; to add a hex or octal notation prefix.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;printf(&quot;Use
# to create hexadecimal prefix &#39;0X&#39; or &#39;0x&#39;. Such as %#X, %#x.\n&quot;, num,
num);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&amp;gt;Use # to create hexadecimal prefix
&#39;0X&#39; or &#39;0x&#39;. Such as 0XFFFF, 0xffff.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;printf(&quot;Use
# to prefix octal with 0. Such as %#o.\n&quot;, num);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&amp;gt;Use # to
prefix octal with 0. Such as 0177777.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;int * pNum =
&amp;amp;num;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;printf(&quot;It
works with pointers. Such as %#X, %#x.\n\n&quot;, pNum, pNum);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&amp;gt;It works
with pointers. Such as 0X34EDD8, 0x34edd8.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;b&gt;Floating-point Numbers.&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
Floating point numbers use the &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;f&lt;/span&gt;
specifier such as &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;%f&lt;/span&gt;.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;float
irrational = 123.456789;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;double
irrational2 = 123.456789;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;printf(&quot;Default:
%f \n&quot;, irrational);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;printf(&quot;Default:
%f \n&quot;, irrational2);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&amp;gt;Default:
123.456787&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&amp;gt;Default:
123.456789&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
Set shorter decimal points.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;printf(&quot;4
decimal points: %.4f \n&quot;, irrational);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;printf(&quot;4
decimal points: %.4f \n&quot;, irrational2);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&amp;gt;4 decimal
points: 123.4568&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&amp;gt;4 decimal
points: 123.4568&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
Set longer decimal points.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;printf(&quot;14
decimal points: %.14f \n&quot;, irrational);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;printf(&quot;14
decimal points: %.14f \n&quot;, irrational2);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&amp;gt;14
decimal points: 123.45678710937500&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&amp;gt;14
decimal points: 123.45678900000000&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;b&gt;Plus or Minus.&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
The flag + will show a plus sign or minus sign before a
number.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;Salary =
375000;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;Bonus =
-27500,&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;printf(&quot;Salary
and bonus: %+d, %+d.\n&quot;, Salary, Bonus);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&amp;gt;Salary
and bonus: +375000, -27500.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;b&gt;Padding With Zeroes.&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
The flag 0 (zero) places zeroes in front of a number. It
only applies if a width has been specified.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;Salary =
375000;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;Bonus =
27500,&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;printf(&quot;Salary
is: %08d.\n&quot;, Salary);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;printf(&quot;Bonus&amp;nbsp; is: %08d.\n&quot;, Bonus);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;printf(&quot;Salary
is: %0d.\n&quot;, Salary);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&amp;gt;Salary
is: 00375000.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&amp;gt;Bonus&amp;nbsp; is: 00027500.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&amp;gt;Salary
is: 375000.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;b&gt;Scientific Notation.&lt;/b&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
Use %e or %E with a floating point number to display it in
scientific notation. A number is formatted as: x.&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;xxxxxxEnnn&lt;/span&gt;.
The decimal equivalent is x.xxxxxx multiplied by 10 to the power of &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;nnn&lt;/span&gt;.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;double
Notation = 100;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;printf(&quot;100
is: %E.\n&quot;, Notation);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;100 is: 1.000000E+002. &lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
In base 10, a number greater than zero has 1s, 10s, 100s
etc. So, 100 is 1 one-hundred. A common mistake happens when a number is less
than zero. 0.001 is not 1/100&lt;sup&gt;&lt;/sup&gt; but 1/1000. So, 0.1 is
tenths, 0.01 is hundreds, 0.001 thousands and so on.&lt;/div&gt;
&amp;nbsp;

&lt;br /&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;Notation =
1.0/100.0;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;printf(&quot;1/100
is: %f or %E.\n&quot;, Notation, Notation);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;1/100 is: 0.010000 or 1.000000E-002.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;double
LargeNum = 123456789123;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;printf(&quot;Number
using E: %E.\n&quot;, LargeNum);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;printf(&quot;Number
using e: %e.\n&quot;, LargeNum);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&amp;gt;Number
using E: 1.234568E+011.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&amp;gt;Number
using e: 1.234568e+011.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;printf(&quot;Specify
width: %15E.\n&quot;, LargeNum);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;printf(&quot;Specify
decimals: %.2E.\n&quot;, LargeNum);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&amp;gt;Specify
width:&amp;nbsp;&amp;nbsp; 1.234568E+011.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&amp;gt;Specify
decimals: 1.23E+011. &lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;double
SmallNum = 0.123456789123;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;printf(&quot;Number
using E: %E.\n&quot;, SmallNum);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&amp;gt;Number
using E: 1.234568E-001.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
The scientific notation doesn&#39;t work with integer data
types.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;int Num =
100;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;printf(&quot;Doesn&#39;t
work with integers: %E.\n&quot;, Num);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&amp;gt;Doesn&#39;t
work with integers: 5.820601E-308.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lessonsincoding.blogspot.com/feeds/7497861264315431966/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://lessonsincoding.blogspot.com/2012/04/printf-function-in-c-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5207350420173720706/posts/default/7497861264315431966'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5207350420173720706/posts/default/7497861264315431966'/><link rel='alternate' type='text/html' href='http://lessonsincoding.blogspot.com/2012/04/printf-function-in-c-c.html' title='The printf Function in C &amp; C++'/><author><name>James Piper</name><uri>http://www.blogger.com/profile/12387224587116087657</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGQ4ESUam_EJLtqp-f18iDIo2m7iCu_98TmJKP8if7vNZ76wasSEUxtnQLbxLqMcA2n9ozNH5PtbOy--l1i2r1znz7zBuCRwmXJOZCl1W_2WuKBPIJENOsjUnf27ltTw/s220/james_piper+sqr+image.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5207350420173720706.post-352809125114300369</id><published>2012-03-28T19:03:00.000-04:00</published><updated>2012-03-28T19:03:24.570-04:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C"/><category scheme="http://www.blogger.com/atom/ns#" term="C++"/><category scheme="http://www.blogger.com/atom/ns#" term="cstdio library"/><title type='text'>Using stdin &amp; stdout in C &amp; C++</title><content type='html'>&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:BrowserLevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&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 class=&quot;eNoIndent&quot;&gt;
Normally if I wanted to send some data to the screen (the console
or &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;stdout&lt;/span&gt;),
I&#39;d use the &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;printf&lt;/span&gt; function.
Here&#39;s an example.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;background: yellow; font-family: &amp;quot;Courier New&amp;quot;; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-highlight: yellow;&quot;&gt;printf&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;(&quot;There
are %d polar bears outside your window.&quot;, BearCount);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
It works great. And if I wanted to send the same information
to a file, I would use the &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;fprintf&lt;/span&gt; function. It works the same way except you must
specify a file to use. Such as:&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;// Declare pointer to the file.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;FILE* pFileHandle;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;// Saves the file in the EXE folder.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;char Filename[] = &quot;MyFile.txt&quot;;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;// Open file for writing.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;pFileHandle = fopen(Filename, &quot;w&quot;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;// Write data to file.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;background: yellow; font-family: &amp;quot;Courier New&amp;quot;; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-highlight: yellow;&quot;&gt;fprintf&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;(&lt;span style=&quot;background: yellow; mso-highlight: yellow;&quot;&gt;pFileHandle&lt;/span&gt; , &quot;(&quot;There
really are %d polar bears outside your window.\n\n&quot;, BearCount);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;// Close the file.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;int iReturn = 0;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;iReturn = fclose(pFileHandle);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
What if I wanted to send the data to the screen or a file or
both? While the standard I/O library creates a type FILE for handling files, it
also creates the objects &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;stdin&lt;/span&gt; and &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;stdout&lt;/span&gt;. I can use the same &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;fprintf&lt;/span&gt;
function in both cases and write code to change the value of &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;pFileHandle.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
For a file,&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;pFileHandle = fopen(…&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
but for the screen use:&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;pFileHandle = &lt;span style=&quot;background: yellow; mso-highlight: yellow;&quot;&gt;stdout&lt;/span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;fprintf(pFileHandle , &quot;Print some data to a text
file.\n\n&quot;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
OR&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;fprintf(&lt;span style=&quot;background: yellow; mso-highlight: yellow;&quot;&gt;stdout&lt;/span&gt;,
&quot;Print some data to stdout.\n\n&quot;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
The same principle applies to reading data from a file or
from the keyboard (i.e., &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;stdin&lt;/span&gt;). I can use the &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;fgets&lt;/span&gt; function for either.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
From a file with,&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;fgets(Text, num, pFileHandle);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
or from the standard input:&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;fgets(Text, num, stdin);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
Data to a maximum length of &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;num&lt;/span&gt; is stored in the character
array &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;Text&lt;/span&gt;.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&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:BrowserLevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&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;/div&gt;
The reason for doing this should be obvious. You can easily
switch between a file or standard I/O without repeating your code. &lt;br /&gt;
&amp;nbsp;&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:BrowserLevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&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 class=&quot;eNoIndent&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;Test Code.&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
I tested the functions in Visual C++ 2010 as an console
application.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: green; font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;// The
standard library includes the system function.&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt; &lt;span style=&quot;color: #a31515;&quot;&gt;&amp;lt;cstdlib&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: green; font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;// C++
standard I/O library.&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt; &lt;span style=&quot;color: #a31515;&quot;&gt;&amp;lt;cstdio&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: green; font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;//
Function prototypes.&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt; DataOut(FILE*
pFile);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt; DataIn(FILE* pFile,
&lt;span style=&quot;color: blue;&quot;&gt;char&lt;/span&gt;* text);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: green; font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;// Max
length of text input.&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt; &lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; MAXLEN = 80;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt; main()&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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: green;&quot;&gt;// Using stdin
&amp;amp; stdout in C &amp;amp; C++&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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: green;&quot;&gt;// Header.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;Using
stdin &amp;amp; stdout instead of a File\n\n\n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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: green;&quot;&gt;// Output.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;*****
OUTPUT *****\n\n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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: green;&quot;&gt;// Declare
pointer to the file.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;FILE* pFileHandle;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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: green;&quot;&gt;// Saves the file
in the EXE folder.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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: blue;&quot;&gt;char&lt;/span&gt;
Filename[] = &lt;span style=&quot;color: #a31515;&quot;&gt;&quot;MyFile.txt&quot;&lt;/span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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: green;&quot;&gt;// Open file.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;pFileHandle = fopen(Filename, &lt;span style=&quot;color: #a31515;&quot;&gt;&quot;w&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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: green;&quot;&gt;// Write data to
file.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;DataOut(pFileHandle);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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: green;&quot;&gt;// Close the
file.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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: blue;&quot;&gt;int&lt;/span&gt; iReturn
= 0;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;iReturn = fclose(pFileHandle);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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: green;&quot;&gt;// Do the same
but send to stdout.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;DataOut(stdout);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;\n\n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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: green;&quot;&gt;// Input.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;*****
INPUT *****\n\n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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: green;&quot;&gt;// Declarations.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&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:BrowserLevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&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;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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: blue;&quot;&gt;char&lt;/span&gt;
readline[MAXLEN];&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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: green;&quot;&gt;// Open file.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;pFileHandle = fopen(Filename, &lt;span style=&quot;color: #a31515;&quot;&gt;&quot;r&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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: green;&quot;&gt;// Get data.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;DataIn(pFileHandle, readline);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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: green;&quot;&gt;// Close the
file.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;iReturn = fclose(pFileHandle);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&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:BrowserLevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&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;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;From
the file: %s\n&quot;&lt;/span&gt;, readline);&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;&amp;nbsp;&lt;/span&gt;

&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;Input
with fgets: &quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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: green;&quot;&gt;// Get data.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;pFileHandle = stdin;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;DataIn(pFileHandle, readline);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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: green;&quot;&gt;// OR
DataIn(stdin, readline);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&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:BrowserLevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&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;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;Your
input: %s\n&quot;&lt;/span&gt;, readline);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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: green;&quot;&gt;// Keep console
window open.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;system(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;pause&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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: green;&quot;&gt;// Return some
value.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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: blue;&quot;&gt;return&lt;/span&gt; 0;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;} &lt;span style=&quot;color: green;&quot;&gt;// end main&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt; DataOut(FILE*
pFile)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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: green;&quot;&gt;// Code to send
data to file or screen.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;fprintf(pFile, &lt;span style=&quot;color: #a31515;&quot;&gt;&quot;Print
some data to a text file or to the screen.\n\n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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: blue;&quot;&gt;return&lt;/span&gt; 0;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt; DataIn(FILE* pFile,
&lt;span style=&quot;color: blue;&quot;&gt;char&lt;/span&gt;* text)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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: green;&quot;&gt;// Code to send
data to file or screen.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&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:BrowserLevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&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;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;fgets(text, MAXLEN, pFile);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&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: blue;&quot;&gt;return&lt;/span&gt; 0;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; mso-bidi-font-family: Consolas;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&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:BrowserLevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&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 class=&quot;eNoIndent&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;Output.&lt;/b&gt;&lt;/div&gt;
&amp;nbsp; &lt;br /&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/AVvXsEgzuKtp79Ta5EAIsHvK-OFz-GPsni9BIJB41L7nse22dAQSSAtO17fLfQVb_yjJfRvZLbb4QVUM4Lu9W6YOBH8Lu5pkRnM0FP_dUdQW_t92TtK7YqWsZ5VZeFJ1q4i3sX2m_B-ACeUPdD0/s1600/2012.03.27+-+LessonsInCoding+-+Using+stdin+&amp;amp;+stdout+in+C+&amp;amp;+C+++A.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;203&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgzuKtp79Ta5EAIsHvK-OFz-GPsni9BIJB41L7nse22dAQSSAtO17fLfQVb_yjJfRvZLbb4QVUM4Lu9W6YOBH8Lu5pkRnM0FP_dUdQW_t92TtK7YqWsZ5VZeFJ1q4i3sX2m_B-ACeUPdD0/s400/2012.03.27+-+LessonsInCoding+-+Using+stdin+&amp;amp;+stdout+in+C+&amp;amp;+C+++A.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&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/AVvXsEirDDI1k9yrmc0dEQOL6-E-T1NoT2iOjuKSbdiZ6I6H5y8qxir4D5R-YMAjtAoqX7-8ldZEBCbfL62OpXHiWL9AGIRgGY2ToEV4cS6KWW5aTuOpqodBflAQEoxuFSNAecCDcJ155IqE890/s1600/2012.03.27+-+LessonsInCoding+-+Using+stdin+%2526+stdout+in+C+%2526+C%252B%252B+B.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;283&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEirDDI1k9yrmc0dEQOL6-E-T1NoT2iOjuKSbdiZ6I6H5y8qxir4D5R-YMAjtAoqX7-8ldZEBCbfL62OpXHiWL9AGIRgGY2ToEV4cS6KWW5aTuOpqodBflAQEoxuFSNAecCDcJ155IqE890/s400/2012.03.27+-+LessonsInCoding+-+Using+stdin+%2526+stdout+in+C+%2526+C%252B%252B+B.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lessonsincoding.blogspot.com/feeds/352809125114300369/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://lessonsincoding.blogspot.com/2012/03/using-stdin-stdout-in-c-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5207350420173720706/posts/default/352809125114300369'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5207350420173720706/posts/default/352809125114300369'/><link rel='alternate' type='text/html' href='http://lessonsincoding.blogspot.com/2012/03/using-stdin-stdout-in-c-c.html' title='Using stdin &amp; stdout in C &amp; C++'/><author><name>James Piper</name><uri>http://www.blogger.com/profile/12387224587116087657</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGQ4ESUam_EJLtqp-f18iDIo2m7iCu_98TmJKP8if7vNZ76wasSEUxtnQLbxLqMcA2n9ozNH5PtbOy--l1i2r1znz7zBuCRwmXJOZCl1W_2WuKBPIJENOsjUnf27ltTw/s220/james_piper+sqr+image.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgzuKtp79Ta5EAIsHvK-OFz-GPsni9BIJB41L7nse22dAQSSAtO17fLfQVb_yjJfRvZLbb4QVUM4Lu9W6YOBH8Lu5pkRnM0FP_dUdQW_t92TtK7YqWsZ5VZeFJ1q4i3sX2m_B-ACeUPdD0/s72-c/2012.03.27+-+LessonsInCoding+-+Using+stdin+&amp;+stdout+in+C+&amp;+C+++A.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5207350420173720706.post-6326971647356728116</id><published>2012-03-27T15:33:00.000-04:00</published><updated>2012-03-27T20:56:11.568-04:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C"/><category scheme="http://www.blogger.com/atom/ns#" term="C++"/><category scheme="http://www.blogger.com/atom/ns#" term="cstdio library"/><title type='text'>The fprintf Function in C &amp; C++</title><content type='html'>&lt;br /&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
You can open a text or binary file with &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;fopen&lt;/span&gt; and close it with &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;fclose&lt;/span&gt;.
(See &lt;a href=&quot;http://lessonsincoding.blogspot.ca/2012/03/fopen-and-fclose-functions-in-c-c.html&quot;&gt;here&lt;/a&gt;.)
The &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;fprintf&lt;/span&gt;
function allows you to “print” data to a text file. It is similar to the &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;printf&lt;/span&gt;
function except the output goes to a file instead of the standard output.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
A note on text files versus binary files. If you open a text
file with an editor program, chances are you can read and make some sense of what’s
there. Not so with a binary file. The binary file is raw data in the way
variables stored in memory are raw data—binary data. But text files store
binary data as well, but along the way, it’s converted to a human readable form
using an ASCII table or Unicode character set. So while you may write “Hello
World” to a text file and see it as such, it is being converted to some binary
code.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
Back to the &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;fprintf&lt;/span&gt; function. The same code
explains it.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;Test Code.&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
I tested the functions in Visual C++ 2010 as an console
application.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: green; font-family: Consolas;&quot;&gt;// The
standard library includes the system function.&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt; &lt;span style=&quot;color: #a31515;&quot;&gt;&amp;lt;cstdlib&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: green; font-family: Consolas;&quot;&gt;// C++
standard I/O library.&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt; &lt;span style=&quot;color: #a31515;&quot;&gt;&amp;lt;cstdio&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;span style=&quot;color: blue; font-family: Consolas;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt; main()&lt;/span&gt;

&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Header.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;\&quot;Print\&quot;
Data To A Text File\n\n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Pointer to the
file.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FILE* pFileHandle;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Puts the file
in the project path.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;char&lt;/span&gt;
Filename[] = &lt;span style=&quot;color: #a31515;&quot;&gt;&quot;MyFile.txt&quot;&lt;/span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Version 1.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// w attribute
for writing to the file.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// If the file
does not exist, it is created.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Any existing
file content is overwritten.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;File
attribute: w - (over) write\n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pFileHandle = fopen(Filename, &lt;span style=&quot;color: #a31515;&quot;&gt;&quot;w&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Write data to
file.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fprintf(pFileHandle , &lt;span style=&quot;color: #a31515;&quot;&gt;&quot;\&quot;Print\&quot; Data To A Text File\n\n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fprintf(pFileHandle , &lt;span style=&quot;color: #a31515;&quot;&gt;&quot;Writing some data to a text file.\n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fprintf(pFileHandle , &lt;span style=&quot;color: #a31515;&quot;&gt;&quot;Any existing data in the file is lost.\n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Close the
file.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; iReturn
= 0;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; iReturn = fclose(pFileHandle);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Version 2.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// a attribute
for appending to the file.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// If the file
does not exist, it is created.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Any existing
file content remains.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;File
attribute: a - appending\n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pFileHandle = fopen(Filename, &lt;span style=&quot;color: #a31515;&quot;&gt;&quot;a&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Write data to
file.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fprintf(pFileHandle , &lt;span style=&quot;color: #a31515;&quot;&gt;&quot;With appending mode, text is added to the
file.\n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Close the
file.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; iReturn = fclose(pFileHandle);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Version 3.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// What happens
when you try to write data to a file opened for reading.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;File
attribute: r - reading\n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pFileHandle = fopen(Filename, &lt;span style=&quot;color: #a31515;&quot;&gt;&quot;r&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Write data to
file.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fprintf(pFileHandle , &lt;span style=&quot;color: #a31515;&quot;&gt;&quot;With reading mode, text isn&#39;t added to the
file.\n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// There is no
run-time error or compile error.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Close the
file.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; iReturn = fclose(pFileHandle);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Keep console
window open.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; system(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;pause&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Return some
value.&lt;/span&gt;&lt;/span&gt;

&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt; 0;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;} &lt;span style=&quot;color: green;&quot;&gt;// end main&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;Text File.&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&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/AVvXsEjsW0ZlB-hB9tse3fADr1vfSawAGG4ZX47c1mdlwPyjkfsI2_w2p_EfWEFlw6Xt9tY_7KrZUZ7oXKGgj7leDJvPthhthyphenhyphenkmWeEf64AklDPiazmtVnunoedqv1juHaxRdEPaBINc5upBQ0o/s1600/2012.03.26+-+LessonsInCoding+-+The+fprintf+Functions+in+C+&amp;amp;+C++.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;285&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjsW0ZlB-hB9tse3fADr1vfSawAGG4ZX47c1mdlwPyjkfsI2_w2p_EfWEFlw6Xt9tY_7KrZUZ7oXKGgj7leDJvPthhthyphenhyphenkmWeEf64AklDPiazmtVnunoedqv1juHaxRdEPaBINc5upBQ0o/s400/2012.03.26+-+LessonsInCoding+-+The+fprintf+Functions+in+C+&amp;amp;+C++.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lessonsincoding.blogspot.com/feeds/6326971647356728116/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://lessonsincoding.blogspot.com/2012/03/fprintf-functions-in-c-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5207350420173720706/posts/default/6326971647356728116'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5207350420173720706/posts/default/6326971647356728116'/><link rel='alternate' type='text/html' href='http://lessonsincoding.blogspot.com/2012/03/fprintf-functions-in-c-c.html' title='The fprintf Function in C &amp; C++'/><author><name>James Piper</name><uri>http://www.blogger.com/profile/12387224587116087657</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGQ4ESUam_EJLtqp-f18iDIo2m7iCu_98TmJKP8if7vNZ76wasSEUxtnQLbxLqMcA2n9ozNH5PtbOy--l1i2r1znz7zBuCRwmXJOZCl1W_2WuKBPIJENOsjUnf27ltTw/s220/james_piper+sqr+image.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjsW0ZlB-hB9tse3fADr1vfSawAGG4ZX47c1mdlwPyjkfsI2_w2p_EfWEFlw6Xt9tY_7KrZUZ7oXKGgj7leDJvPthhthyphenhyphenkmWeEf64AklDPiazmtVnunoedqv1juHaxRdEPaBINc5upBQ0o/s72-c/2012.03.26+-+LessonsInCoding+-+The+fprintf+Functions+in+C+&amp;+C++.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5207350420173720706.post-4029417842197000412</id><published>2012-03-26T18:01:00.000-04:00</published><updated>2012-03-26T18:01:28.216-04:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C"/><category scheme="http://www.blogger.com/atom/ns#" term="C++"/><category scheme="http://www.blogger.com/atom/ns#" term="Logic Operators"/><title type='text'>A Common Error In C &amp; C++</title><content type='html'>&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:BrowserLevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&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 class=&quot;eNoIndent&quot;&gt;
In C and C++ there’s a difference between the &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;=&lt;/span&gt; assignment operator and the &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;==&lt;/span&gt;
logical equality operator. In many other languages, the equal sign is used in
both situations; therefore, it’s easy to use &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;=&lt;/span&gt; when you want to use &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;==&lt;/span&gt;.
&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
You compiler won’t tap you on the shoulder to tell you made
a mistake. It will happily chug along. There is no syntax error. The problem
happens when you run the program. Besides, assigning the value to the variable,
I tested some code to see what would happen.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
Take this scenario.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-bidi-font-family: &amp;quot;Times New Roman&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;int a = 0;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-bidi-font-family: &amp;quot;Times New Roman&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;if (a = 1){…&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
First the program will assign 1 to &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;a &lt;/span&gt;then it will
evaluate the expression &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;a&lt;/span&gt; as being non-zero (i.e., not false) and execute any
code for the true condition.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
This code&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-bidi-font-family: &amp;quot;Times New Roman&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;if (a = 0){…&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
assigns zero to &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;a&lt;/span&gt; and results in a false
condition.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
Similar events happen with the &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;do&lt;/span&gt; and &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;while&lt;/span&gt;
loops.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
How about a &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;for&lt;/span&gt; loop like this?&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-bidi-font-family: &amp;quot;Times New Roman&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;for (i = 0; a = i;
++i) {…&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
Since &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;a&lt;/span&gt; equals &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;i&lt;/span&gt; equals &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;0&lt;/span&gt;, it’s false and
the for loop doesn’t execute any code under its control.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
On the other hand, this code,&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-bidi-font-family: &amp;quot;Times New Roman&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;for (i = 1; a = i;
++i) {…&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
creates an infinite loop. Be ready to hit break.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
It’s the easiest mistake to make in C and C++ especially if
you’re working with other languages at the same time.&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lessonsincoding.blogspot.com/feeds/4029417842197000412/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://lessonsincoding.blogspot.com/2012/03/common-error-in-c-c.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5207350420173720706/posts/default/4029417842197000412'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5207350420173720706/posts/default/4029417842197000412'/><link rel='alternate' type='text/html' href='http://lessonsincoding.blogspot.com/2012/03/common-error-in-c-c.html' title='A Common Error In C &amp; C++'/><author><name>James Piper</name><uri>http://www.blogger.com/profile/12387224587116087657</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGQ4ESUam_EJLtqp-f18iDIo2m7iCu_98TmJKP8if7vNZ76wasSEUxtnQLbxLqMcA2n9ozNH5PtbOy--l1i2r1znz7zBuCRwmXJOZCl1W_2WuKBPIJENOsjUnf27ltTw/s220/james_piper+sqr+image.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5207350420173720706.post-4217221871836552449</id><published>2012-03-25T19:59:00.000-04:00</published><updated>2012-03-25T20:01:25.601-04:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C"/><category scheme="http://www.blogger.com/atom/ns#" term="C++"/><category scheme="http://www.blogger.com/atom/ns#" term="math"/><title type='text'>Modulus With Negative Numbers in C &amp; C++</title><content type='html'>&lt;br /&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
What it is correct answer when calculating the modulus of
two numbers when one of the numbers is negative? When it comes to computers,
the answer is: it depends.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
The starting point is basic division of integers. Take a &lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;dividend&lt;/i&gt;, &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;a&lt;/span&gt;,
and divide it by the &lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;divisor&lt;/i&gt;, &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;b&lt;/span&gt;,
to get some result that is a &lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;quotient&lt;/i&gt;,
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;q&lt;/span&gt;,
and a &lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;remainder&lt;/i&gt;, &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;r&lt;/span&gt;,
if any. The modulus of &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;a&lt;/span&gt; and &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;b&lt;/span&gt; is the remainder, &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;r&lt;/span&gt;.
This division theorem works for all numbers that are integers, provided b is
not zero. &lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&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/AVvXsEh9-P90kTAHJ9dMFqMPwLyM8MY2SCVbdH4DL4N6_Q5ME_52rRVaEKduVMyigobm-KegVnrmXB4COJGvuITWvrz1mzREt-yLpPnuyyEAbaiDjk0jIeumFgjznMUc8HuwDvXTzUBZ3335uNQ/s1600/2012.03.25+-+LessonsInCoding+-+Modulus+With+Negative+Numbers+in+C+&amp;amp;+C+++A.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;357&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh9-P90kTAHJ9dMFqMPwLyM8MY2SCVbdH4DL4N6_Q5ME_52rRVaEKduVMyigobm-KegVnrmXB4COJGvuITWvrz1mzREt-yLpPnuyyEAbaiDjk0jIeumFgjznMUc8HuwDvXTzUBZ3335uNQ/s400/2012.03.25+-+LessonsInCoding+-+Modulus+With+Negative+Numbers+in+C+&amp;amp;+C+++A.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiG3vOy3MpG_eYO1doNKJRJY2GbL9ydyuBtCYjX79MxxWpPwBm1qXz5xLOikr-mJx-PxWTq4pCibP1EeG-p3FUL-20qTZ3vqQs6SwIehVYYhje9ihmFN65VN4IC6o6qe0Cq7gvGc1XQWzk/s1600/2012.03.25+-+LessonsInCoding+-+Modulus+With+Negative+Numbers+in+C+%2526+C%252B%252B+B.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;309&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiG3vOy3MpG_eYO1doNKJRJY2GbL9ydyuBtCYjX79MxxWpPwBm1qXz5xLOikr-mJx-PxWTq4pCibP1EeG-p3FUL-20qTZ3vqQs6SwIehVYYhje9ihmFN65VN4IC6o6qe0Cq7gvGc1XQWzk/s320/2012.03.25+-+LessonsInCoding+-+Modulus+With+Negative+Numbers+in+C+%2526+C%252B%252B+B.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&amp;nbsp; &lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
If the &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;a&lt;/span&gt; and &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;b&lt;/span&gt; have the same sign (both
positive or both negative), the quotient is positive. If their signs are
opposite (one negative, one positive), the quotient is negative. What about the
modulus? It’s easy to think the same process applies, but does it? No.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
To calculate &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;r&lt;/span&gt;, use the division equation for
known values of &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;a&lt;/span&gt;, &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;b&lt;/span&gt; and &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;q&lt;/span&gt;.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
The following code in Visual C++ 2010 shows the four different
possibilities pos+/neg- values for &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;a&lt;/span&gt; and &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;b&lt;/span&gt;.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&amp;nbsp;&lt;span style=&quot;color: green; font-family: Consolas;&quot;&gt;//
Header.&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;Modulus With Negative Numbers\n\n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;a x b = q + r OR b x q + r = a\n\n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt; a = 7;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt; b = 2; &lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;a = %d, b = %d \n&quot;&lt;/span&gt;, a, b);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;q: %d / %d = %d \n&quot;&lt;/span&gt;, a, b, a / b);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;r: %d mod %d = %d \n&quot;&lt;/span&gt;, a, b, a % b);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: green; font-family: Consolas;&quot;&gt;// 2 x 3
+ 1 = 7&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;%d x %d + %d = %d \n\n&quot;&lt;/span&gt;, b, a / b, a %
b, a);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;a = -7;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;b = 2; &lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;a = %d, b = %d \n&quot;&lt;/span&gt;, a, b);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;q: %d / %d = %d \n&quot;&lt;/span&gt;, a, b, a / b);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;r: %d mod %d = %d \n&quot;&lt;/span&gt;, a, b, a % b);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: green; font-family: Consolas;&quot;&gt;// 2 x
-3 - 1 = -7&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;%d x %d + %d = %d \n\n&quot;&lt;/span&gt;, b, a / b, a %
b, a);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;a = 7;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;b = -2; &lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;a = %d, b = %d \n&quot;&lt;/span&gt;, a, b);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;q: %d / %d = %d \n&quot;&lt;/span&gt;, a, b, a / b);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;r: %d mod %d = %d \n&quot;&lt;/span&gt;, a, b, a % b);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: green; font-family: Consolas;&quot;&gt;// -2 x
-3 + 1 = 7&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;%d x %d + %d = %d \n\n&quot;&lt;/span&gt;, b, a / b, a %
b, a);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;a = -7;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;b = -2; &lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;a = %d, b = %d \n&quot;&lt;/span&gt;, a, b);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;q: %d / %d = %d \n&quot;&lt;/span&gt;, a, b, a / b);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;r: %d mod %d = %d \n&quot;&lt;/span&gt;, a, b, a % b);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: green; font-family: Consolas;&quot;&gt;// -2 x
3 - 1 = -7&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;%d x %d + %d = %d \n\n&quot;&lt;/span&gt;, b, a / b, a %
b, a);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;Output.&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&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/AVvXsEiUuLIIpcBL4LYfJ-PnpUGYnY8hGQgMEzJ_PY6b4NTB4q2WeG6AE_Rums-wdXmPgnXKjskyFQfoovuAWHApAOt68lQV4mhHJRGnf1lBecLduoMN8DdtM7pquiyDIen3mYlvZnxvRZNKX3w/s1600/2012.03.25+-+LessonsInCoding+-+Modulus+With+Negative+Numbers+in+C+%2526+C%252B%252B+C.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;210&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiUuLIIpcBL4LYfJ-PnpUGYnY8hGQgMEzJ_PY6b4NTB4q2WeG6AE_Rums-wdXmPgnXKjskyFQfoovuAWHApAOt68lQV4mhHJRGnf1lBecLduoMN8DdtM7pquiyDIen3mYlvZnxvRZNKX3w/s400/2012.03.25+-+LessonsInCoding+-+Modulus+With+Negative+Numbers+in+C+%2526+C%252B%252B+C.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&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:BrowserLevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&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 class=&quot;eNoIndent&quot;&gt;
You will get the same results in Visual Basic.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
When it comes to using the modulus operator, test it with a
range of expected parameters to make sure it gives the result you expect and
want. Not all versions of C or C++ or other languages behave the same. If all
else fails, create your own modulus function to work the way you want.&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lessonsincoding.blogspot.com/feeds/4217221871836552449/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://lessonsincoding.blogspot.com/2012/03/modulus-with-negative-numbers-in-c-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5207350420173720706/posts/default/4217221871836552449'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5207350420173720706/posts/default/4217221871836552449'/><link rel='alternate' type='text/html' href='http://lessonsincoding.blogspot.com/2012/03/modulus-with-negative-numbers-in-c-c.html' title='Modulus With Negative Numbers in C &amp; C++'/><author><name>James Piper</name><uri>http://www.blogger.com/profile/12387224587116087657</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGQ4ESUam_EJLtqp-f18iDIo2m7iCu_98TmJKP8if7vNZ76wasSEUxtnQLbxLqMcA2n9ozNH5PtbOy--l1i2r1znz7zBuCRwmXJOZCl1W_2WuKBPIJENOsjUnf27ltTw/s220/james_piper+sqr+image.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh9-P90kTAHJ9dMFqMPwLyM8MY2SCVbdH4DL4N6_Q5ME_52rRVaEKduVMyigobm-KegVnrmXB4COJGvuITWvrz1mzREt-yLpPnuyyEAbaiDjk0jIeumFgjznMUc8HuwDvXTzUBZ3335uNQ/s72-c/2012.03.25+-+LessonsInCoding+-+Modulus+With+Negative+Numbers+in+C+&amp;+C+++A.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5207350420173720706.post-8427105054366125195</id><published>2012-03-24T19:49:00.000-04:00</published><updated>2012-03-25T15:12:24.730-04:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C"/><category scheme="http://www.blogger.com/atom/ns#" term="C++"/><category scheme="http://www.blogger.com/atom/ns#" term="cstdio library"/><title type='text'>The fopen and fclose Functions in C &amp; C++</title><content type='html'>&lt;br /&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
The &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;cstdio&lt;/span&gt;
library provides two functions for opening and closing a text file: &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;fopen&lt;/span&gt;,
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;fclose&lt;/span&gt;.
Both functions use a FILE type pointer variable. The FILE type is defined in
the library.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
The &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;fopen&lt;/span&gt; function requires a filename and a tag to
specify the mode of access (read, write, append etc.) It returns a handle for
accessing the file. The &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;fclose&lt;/span&gt; function closes the file associated with the handle.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
The first step is to create a pointer of the FILE type.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;FILE * pFileHandle;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
You open a text file for reading with this code:&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;pFileHandle =
fopen(&quot;Filename&quot;, &lt;span style=&quot;background: none repeat scroll 0% 0% yellow;&quot;&gt;&quot;r&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
If the file does not exist, the functions returns NULL,
otherwise it holds a handle for the opened file.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
The file mode, “w” opens a file for writing. If the file
does not exist, it is created. If the file exists, any existing data is
overwritten.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;pFileHandle =
fopen(&quot;Filename&quot;, &lt;span style=&quot;background: none repeat scroll 0% 0% yellow;&quot;&gt;&quot;w&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
Finally, you can use the “a’ tag to append to a file. If the
file does not exist, it is created. If the file exists, data is added to the
end of the file.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;pFileHandle =
fopen(&quot;Filename&quot;, &lt;span style=&quot;background: none repeat scroll 0% 0% yellow;&quot;&gt;&quot;a&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
While it’s possible to close a file this way,&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;fclose(pFileHandle);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
You should confirm the close function worked by analyzing
the return value such as:&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt; iReturn = 0;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;iReturn = fclose(pFileHandle);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
If the return value is EOF, there was an error closing the
file, otherwise the file was closed.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&amp;nbsp;

&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;Test Code.&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
I tested the functions in Visual C++ 2010 as an console
application.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: green; font-family: Consolas;&quot;&gt;// The
standard library includes the system function.&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt; &lt;span style=&quot;color: #a31515;&quot;&gt;&amp;lt;cstdlib&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: green; font-family: Consolas;&quot;&gt;// C++
standard I/O library.&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt; &lt;span style=&quot;color: #a31515;&quot;&gt;&amp;lt;cstdio&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: green; font-family: Consolas;&quot;&gt;// C++
math library.&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt; &lt;span style=&quot;color: #a31515;&quot;&gt;&amp;lt;cmath&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt; main()&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Header.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;File
Open, File Close.\n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;For
text files.\n\n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Pointer to the
file.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FILE* pFileHandle;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Puts the file
in the project path.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;char&lt;/span&gt;
Filename[] = &lt;span style=&quot;color: #a31515;&quot;&gt;&quot;MyFile.txt&quot;&lt;/span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Version 1.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// r attribute
for reading the file.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Fails to open
if the file does not exist.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;File
attribute: r\n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pFileHandle = fopen(Filename, &lt;span style=&quot;color: #a31515;&quot;&gt;&quot;r&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;if&lt;/span&gt;
(pFileHandle != NULL)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;File
exists.\n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;else&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;File
doesn&#39;t exist.\n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;File
Handle: %X \n\n&quot;&lt;/span&gt;, pFileHandle);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Version 2.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// w attribute
for writing to the file.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// If the file
does not exist, it is created.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Any existing
file content is overwritten.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;File
attribute: w\n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pFileHandle = fopen(Filename, &lt;span style=&quot;color: #a31515;&quot;&gt;&quot;w&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;if&lt;/span&gt;
(pFileHandle != NULL)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;File
exists.\n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;else&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;File doesn&#39;t exist.\n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;File
Handle: %X \n\n&quot;&lt;/span&gt;, pFileHandle);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Version 3.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// a attribute
for appending to the file.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// If the file
does not exist, it is created.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Any existing
file content remains.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;File
attribute: a\n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pFileHandle = fopen(Filename, &lt;span style=&quot;color: #a31515;&quot;&gt;&quot;a&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;if&lt;/span&gt;
(pFileHandle != NULL)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;File
exists.\n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;else&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;File
doesn&#39;t exist.\n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;File
Handle: %X \n\n&quot;&lt;/span&gt;, pFileHandle);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Close the
file.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; iReturn
= 0;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; iReturn = fclose(pFileHandle);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// iReturn = 0 or
false, means success closing the file.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// iReturn = EOF
means an error.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;if&lt;/span&gt; (iReturn
== EOF) &lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;Error
closing the file.\n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;else&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;File
closed.\n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;File
Handle: %X \n\n&quot;&lt;/span&gt;, pFileHandle);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Return some
value.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt; 0;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;} &lt;span style=&quot;color: green;&quot;&gt;// end main&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Output.&lt;/b&gt;&lt;br /&gt;
&lt;br /&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/AVvXsEhjrwGlzxWpH-GwT3QFI-9IdyAsppjE5NA_wEU9uLWgL4vV4PxIHlVM0klVOPhOskkvgkWn7PKwDPBQsQ-jQiwsHWSj7NVpRM6m3pDsrIPdTPjzV2026XlTfzoJvj8tuCRFq-S2oceswjg/s1600/2012.03.24+-+LessonsInCoding+-+The+fopen+and+fclose+Functions+in+C+&amp;amp;+C++.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;203&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjrwGlzxWpH-GwT3QFI-9IdyAsppjE5NA_wEU9uLWgL4vV4PxIHlVM0klVOPhOskkvgkWn7PKwDPBQsQ-jQiwsHWSj7NVpRM6m3pDsrIPdTPjzV2026XlTfzoJvj8tuCRFq-S2oceswjg/s400/2012.03.24+-+LessonsInCoding+-+The+fopen+and+fclose+Functions+in+C+&amp;amp;+C++.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lessonsincoding.blogspot.com/feeds/8427105054366125195/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://lessonsincoding.blogspot.com/2012/03/fopen-and-fclose-functions-in-c-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5207350420173720706/posts/default/8427105054366125195'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5207350420173720706/posts/default/8427105054366125195'/><link rel='alternate' type='text/html' href='http://lessonsincoding.blogspot.com/2012/03/fopen-and-fclose-functions-in-c-c.html' title='The fopen and fclose Functions in C &amp; C++'/><author><name>James Piper</name><uri>http://www.blogger.com/profile/12387224587116087657</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGQ4ESUam_EJLtqp-f18iDIo2m7iCu_98TmJKP8if7vNZ76wasSEUxtnQLbxLqMcA2n9ozNH5PtbOy--l1i2r1znz7zBuCRwmXJOZCl1W_2WuKBPIJENOsjUnf27ltTw/s220/james_piper+sqr+image.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjrwGlzxWpH-GwT3QFI-9IdyAsppjE5NA_wEU9uLWgL4vV4PxIHlVM0klVOPhOskkvgkWn7PKwDPBQsQ-jQiwsHWSj7NVpRM6m3pDsrIPdTPjzV2026XlTfzoJvj8tuCRFq-S2oceswjg/s72-c/2012.03.24+-+LessonsInCoding+-+The+fopen+and+fclose+Functions+in+C+&amp;+C++.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5207350420173720706.post-2756634430991283496</id><published>2012-03-23T19:23:00.000-04:00</published><updated>2012-03-25T15:12:46.942-04:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Cryptography"/><category scheme="http://www.blogger.com/atom/ns#" term="Logic Operators"/><title type='text'>Using XOR To Encrypt Message</title><content type='html'>&lt;br /&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
The XOR logic operator provides a convenient way to encrypt
a message. By encrypt I refer to the technique where a letter of a readable
message is substituted with another letter to make the encrypted message
unreadable. At least at first glance.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
The basic algorithm to encrypt a message is &lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;message letter XOR key letter = encrypted letter&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
and to decrypt it’s: &lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;encrypted letter XOR key letter = message letter.&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
Using the XOR operator with the same key results in symmetry
for encrypting and decrypting. To understand that, take a closer look at what
happens at the bit level.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
I want to encrypt the letter A with the key letter of K.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
A is 0x41 or 0100 0001 and K is 0x4B or 0100 1011.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;A&amp;nbsp;&amp;nbsp;&amp;nbsp; 0100 0001&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;K&amp;nbsp;&amp;nbsp;&amp;nbsp; 0100 1011&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;XOR&amp;nbsp; 0000 1010&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
So my encrypted letter is 0x0A.&amp;nbsp; Given that value and my key of K, I can run
the same process to get the message back.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;Ct&amp;nbsp;&amp;nbsp; 0000 1010&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;K&amp;nbsp;&amp;nbsp;&amp;nbsp; 0100 1011&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;XOR&amp;nbsp; 0100 0001&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
Why does it work? Look at the four possibilities: &lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;tab-stops: .75in 1.25in 2.0in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;A xor&amp;nbsp; K&amp;nbsp; = Ct xor  K&amp;nbsp; = A&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;tab-stops: .75in 1.25in 2.0in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;tab-stops: .75in 1.25in 2.0in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;tab-stops: .75in 1.25in 2.0in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;tab-stops: .75in 1.25in 2.0in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
For each of the four possibilities, using XOR with the same
key value brings you back to the original message.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
Here is some sample code in C/C++.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: green; font-family: Consolas;&quot;&gt;// The
standard library includes the system function.&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt; &lt;span style=&quot;color: #a31515;&quot;&gt;&amp;lt;cstdlib&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt; main()&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;Encrypt
Message Using XOR\n\n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;char&lt;/span&gt; msg = &lt;span style=&quot;color: #a31515;&quot;&gt;&#39;A&#39;&lt;/span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;char&lt;/span&gt; key = &lt;span style=&quot;color: #a31515;&quot;&gt;&#39;K&#39;&lt;/span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;char&lt;/span&gt;
crypto;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Encipher.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; crypto = msg ^ key;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;XOR
of msg (%X) and key (%X) results in %X.\n\n&quot;&lt;/span&gt;, msg, key, crypto);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Decipher.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; msg = crypto ^ key;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;XOR
of crypto (%X) and key (%X) results in %X.\n\n&quot;&lt;/span&gt;, crypto, key, msg);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Keep console
window open.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; system(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;pause&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Return some
value.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt; 0;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;} &lt;span style=&quot;color: green;&quot;&gt;// end main&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;Output.&lt;/b&gt;&lt;/div&gt;
&lt;br /&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/AVvXsEgjKxeVAWoe3_sBIyIKOUOz7-s9qDTvZHkXgIVbdzUygy4vafNDngSRPwjGR0imUXf4ObSvyXMLR_7diiXZt-Q5UKSaZlmt1CarmV2cFujHGzRG6EGjZinNS2POn9l57zgTfeRWEQ4px_s/s1600/2012.03.23+-+LessonsInCoding+-+Using+XOR+To+Encrypt+Message.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;205&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjKxeVAWoe3_sBIyIKOUOz7-s9qDTvZHkXgIVbdzUygy4vafNDngSRPwjGR0imUXf4ObSvyXMLR_7diiXZt-Q5UKSaZlmt1CarmV2cFujHGzRG6EGjZinNS2POn9l57zgTfeRWEQ4px_s/s400/2012.03.23+-+LessonsInCoding+-+Using+XOR+To+Encrypt+Message.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lessonsincoding.blogspot.com/feeds/2756634430991283496/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://lessonsincoding.blogspot.com/2012/03/using-xor-to-encrypt-message.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5207350420173720706/posts/default/2756634430991283496'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5207350420173720706/posts/default/2756634430991283496'/><link rel='alternate' type='text/html' href='http://lessonsincoding.blogspot.com/2012/03/using-xor-to-encrypt-message.html' title='Using XOR To Encrypt Message'/><author><name>James Piper</name><uri>http://www.blogger.com/profile/12387224587116087657</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGQ4ESUam_EJLtqp-f18iDIo2m7iCu_98TmJKP8if7vNZ76wasSEUxtnQLbxLqMcA2n9ozNH5PtbOy--l1i2r1znz7zBuCRwmXJOZCl1W_2WuKBPIJENOsjUnf27ltTw/s220/james_piper+sqr+image.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjKxeVAWoe3_sBIyIKOUOz7-s9qDTvZHkXgIVbdzUygy4vafNDngSRPwjGR0imUXf4ObSvyXMLR_7diiXZt-Q5UKSaZlmt1CarmV2cFujHGzRG6EGjZinNS2POn9l57zgTfeRWEQ4px_s/s72-c/2012.03.23+-+LessonsInCoding+-+Using+XOR+To+Encrypt+Message.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5207350420173720706.post-7878280563967647746</id><published>2012-03-23T14:07:00.000-04:00</published><updated>2012-03-25T15:12:59.677-04:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Windows 7"/><title type='text'>Mouse Over To Activate A Window in Windows 7</title><content type='html'>&lt;div class=&quot;eNoIndent&quot;&gt;
For a while now I’ve been using a computer with Windows 7
and there was one behaviour that was driving me nuts. If I opened up a window
that didn’t fill the screen, say using Notepad to view a text file, within
seconds, the window would disappear. The window below it would now come to the front.
To avoid this problem, I had to quickly move the mouse over the new window
before it would disappear and more times than not, it would disappear.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
I never had this problem with other versions of Windows.
There had to be some setting to change the behaviour. You’d think it had
something to do with the appearance settings, but no. It’s in the mouse
settings.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
From the Control Panel, click on “Ease of Access.”&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&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/AVvXsEi1MEFAueu9wFs_-YtucdYw-8op943_93qHbZXDo3_RmGch1DFobt4LhiulDsoQq1mEqWaUdgF7JmKMFTD9JighN66RtMk6NMNMFu0LIPLtYwhChK0YMsNcytmT9dL33R0Q_pSOBCcki0s/s1600/2012.03.23+-+LessonsInCoding+-+Mouse+Over+To+Activate+A+Window+in+Windows+7a.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;188&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1MEFAueu9wFs_-YtucdYw-8op943_93qHbZXDo3_RmGch1DFobt4LhiulDsoQq1mEqWaUdgF7JmKMFTD9JighN66RtMk6NMNMFu0LIPLtYwhChK0YMsNcytmT9dL33R0Q_pSOBCcki0s/s400/2012.03.23+-+LessonsInCoding+-+Mouse+Over+To+Activate+A+Window+in+Windows+7a.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
Then click on “Change how your mouse works.”&lt;/div&gt;
&lt;br /&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/AVvXsEiJSP6-Hmq8quxJdG3On-n5N-4Cr9PxuveI90oeLnCTlaGcJLcbSzPQoaJvnLwdNhKVwPRcK8QXYQ1uBn-xIFMb7s5Uxln0jc8HOY_aJ77uDN9ZMDSWapMzfxnq_UF1wk2F1IHsrywpoUw/s1600/2012.03.23+-+LessonsInCoding+-+Mouse+Over+To+Activate+A+Window+in+Windows+7b.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;151&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJSP6-Hmq8quxJdG3On-n5N-4Cr9PxuveI90oeLnCTlaGcJLcbSzPQoaJvnLwdNhKVwPRcK8QXYQ1uBn-xIFMb7s5Uxln0jc8HOY_aJ77uDN9ZMDSWapMzfxnq_UF1wk2F1IHsrywpoUw/s400/2012.03.23+-+LessonsInCoding+-+Mouse+Over+To+Activate+A+Window+in+Windows+7b.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
You can toggle “Activate a window by hovering over it with
the mouse.” When it’s enabled, mousing over a window will bring it to the
front.&amp;nbsp; When it’s off, mousing away from
your current window won’t cause it to lose focus. That’s how I want it and
problem solved.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&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/AVvXsEh5NCHTq0LAe1pJ5xODaWx9hyphenhyphenIomxAjJOkQIVL17X5h5B6U3dQJQgQy3dbhNqychyphenhyphenFwwz8E2fBa0T-vnxHruDGaSGT9Myxh9qeAEB8VJYMvkeyMN0ImVuI95i_Jvjk1mLA3cDjF_vE3X-c/s1600/2012.03.23+-+LessonsInCoding+-+Mouse+Over+To+Activate+A+Window+in+Windows+7c.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;300&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5NCHTq0LAe1pJ5xODaWx9hyphenhyphenIomxAjJOkQIVL17X5h5B6U3dQJQgQy3dbhNqychyphenhyphenFwwz8E2fBa0T-vnxHruDGaSGT9Myxh9qeAEB8VJYMvkeyMN0ImVuI95i_Jvjk1mLA3cDjF_vE3X-c/s400/2012.03.23+-+LessonsInCoding+-+Mouse+Over+To+Activate+A+Window+in+Windows+7c.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lessonsincoding.blogspot.com/feeds/7878280563967647746/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://lessonsincoding.blogspot.com/2012/03/mouse-over-to-activate-window-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5207350420173720706/posts/default/7878280563967647746'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5207350420173720706/posts/default/7878280563967647746'/><link rel='alternate' type='text/html' href='http://lessonsincoding.blogspot.com/2012/03/mouse-over-to-activate-window-in.html' title='Mouse Over To Activate A Window in Windows 7'/><author><name>James Piper</name><uri>http://www.blogger.com/profile/12387224587116087657</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGQ4ESUam_EJLtqp-f18iDIo2m7iCu_98TmJKP8if7vNZ76wasSEUxtnQLbxLqMcA2n9ozNH5PtbOy--l1i2r1znz7zBuCRwmXJOZCl1W_2WuKBPIJENOsjUnf27ltTw/s220/james_piper+sqr+image.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1MEFAueu9wFs_-YtucdYw-8op943_93qHbZXDo3_RmGch1DFobt4LhiulDsoQq1mEqWaUdgF7JmKMFTD9JighN66RtMk6NMNMFu0LIPLtYwhChK0YMsNcytmT9dL33R0Q_pSOBCcki0s/s72-c/2012.03.23+-+LessonsInCoding+-+Mouse+Over+To+Activate+A+Window+in+Windows+7a.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5207350420173720706.post-5538476293469586767</id><published>2012-03-17T12:55:00.000-04:00</published><updated>2012-03-25T15:13:19.718-04:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="history"/><category scheme="http://www.blogger.com/atom/ns#" term="log functions"/><category scheme="http://www.blogger.com/atom/ns#" term="math"/><title type='text'>Using Logarithms</title><content type='html'>&lt;br /&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
I was watching a documentary on the history of modern
computers and came across a few interesting items. I say modern computers
because prior to the 1940s, a computer was a person, not a thing. He, primarily,
was a person who computed numbers hours after hour. It wasn’t necessarily
accounting figures, but anything, like artillery tables, navigational guides, or
census statistics. Lots and lots of numbers. Numbers computed without aid of
any mechanical devices.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
If they wanted to add up a series of numbers, they had to
add them up. If they wanted to multiply two numbers, they would consult tables
to find the natural logarithmic of the numbers, add those numbers then find
that sum in another table to give you the multiplied value. Every step of the
process was an opportunity to create an error including the values in the
tables. These books of tables were after all created by humans and contained
errors. Imagine trying to copy out a telephone book by hand and not make a
mistake.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
Sometime in the 19&lt;sup&gt;th&lt;/sup&gt; century Charles Babbage had
the idea of creating a machine to eliminate the human error these computers
created. It’s suggested his initial concept was the start of computers we know today. Perhaps. One of his difficulties was his choice to use the decimal
numbering system instead of binary. Perhaps it wasn’t a choice, just standard
operating procedure. Not thinking outside the box. If he had worked on a binary
system, he may have built the prototype he had in mind.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
And those tables? Here is an example. Say I want to know
what 3.3 times 4.4 is because those are the dimensions of some object. I could
do the multiplication by hand, double check my figures and report the result.
What if I had to do that fifty times in a day? Or more? Look for a faster
approach.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
The natural logarithm of 3.3 is 1.19392247 and for 4.4, it’s
1.48160454. These log numbers come from a table. As with most people, I can add
those numbers together faster than I can multiply them. The result is
2.67552701. Now I find what e to that number is and I come up with 14.52 which is
3.3 times 4.4.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
So,&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div align=&quot;center&quot; class=&quot;eNoIndent&quot; style=&quot;text-align: center;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 16pt;&quot;&gt;e&lt;sup&gt;(ln A + ln B)&lt;/sup&gt; = &lt;/span&gt;A
x B&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
The same works for division.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div align=&quot;center&quot; class=&quot;eNoIndent&quot; style=&quot;text-align: center;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 16pt;&quot;&gt;e&lt;sup&gt;(ln A - ln B)&lt;/sup&gt; = &lt;/span&gt;A
/ B&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
I haven’t figured out how slide rulers work. No need, just curious.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lessonsincoding.blogspot.com/feeds/5538476293469586767/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://lessonsincoding.blogspot.com/2012/03/using-logarithms.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5207350420173720706/posts/default/5538476293469586767'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5207350420173720706/posts/default/5538476293469586767'/><link rel='alternate' type='text/html' href='http://lessonsincoding.blogspot.com/2012/03/using-logarithms.html' title='Using Logarithms'/><author><name>James Piper</name><uri>http://www.blogger.com/profile/12387224587116087657</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGQ4ESUam_EJLtqp-f18iDIo2m7iCu_98TmJKP8if7vNZ76wasSEUxtnQLbxLqMcA2n9ozNH5PtbOy--l1i2r1znz7zBuCRwmXJOZCl1W_2WuKBPIJENOsjUnf27ltTw/s220/james_piper+sqr+image.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5207350420173720706.post-6325209702693376382</id><published>2012-03-17T09:26:00.001-04:00</published><updated>2012-03-25T15:13:31.015-04:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C"/><category scheme="http://www.blogger.com/atom/ns#" term="C++"/><category scheme="http://www.blogger.com/atom/ns#" term="cmath library"/><title type='text'>The tanh Function in C &amp; C++</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
More functions from the&amp;nbsp;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;lt;math.h&amp;gt;&lt;/span&gt; or &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;lt;cmath&amp;gt;&lt;/span&gt; header files. Today it’s
about the &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;tanh&lt;/span&gt; function.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
The &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;tanh&lt;/span&gt;
function returns the hyperbolic tangent for any real number and is defined as
shown below.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&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/AVvXsEh-DkQu-6LkYD4h5cRTysmW-WhT4PWVcceGYavpPA4H6lUrC3n61tVExuMrMQwIOPXIJ1J9hWiLc9HAEet5gbD1WQlqeT4XpCQ6Js2wMOBH56IkH0jSX3YoZ0Gb9V00THGFPZOfZ3vd3P8/s1600/tanh+Function.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;282&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh-DkQu-6LkYD4h5cRTysmW-WhT4PWVcceGYavpPA4H6lUrC3n61tVExuMrMQwIOPXIJ1J9hWiLc9HAEet5gbD1WQlqeT4XpCQ6Js2wMOBH56IkH0jSX3YoZ0Gb9V00THGFPZOfZ3vd3P8/s400/tanh+Function.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&amp;nbsp; &lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&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/AVvXsEipFAPKNjCBeVLp4kNOZcx0MQ4bVLgxSK-BiL_DgZxVp0kpyK19mXoE2BIDdlToBhDEKTCLpSJV_fwj_vpRxyhhGvUtuu79krRIOynML1zUiXvjv9Dlpa9XTERD4HRzpaR6lrYdchxtbww/s1600/Hyperbolic+tangent+Curve.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;267&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEipFAPKNjCBeVLp4kNOZcx0MQ4bVLgxSK-BiL_DgZxVp0kpyK19mXoE2BIDdlToBhDEKTCLpSJV_fwj_vpRxyhhGvUtuu79krRIOynML1zUiXvjv9Dlpa9XTERD4HRzpaR6lrYdchxtbww/s400/Hyperbolic+tangent+Curve.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
From C11 standard.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&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/AVvXsEhrXCJrWSxTfjy6YBZBCbm48lreyG0tFKspwIVQ5a-1F9a1yDTzlUFM072eU7lA4kI2Pl7PpILL27gQWSOb8kwghT8X8btcM3iyZhgPY-U-QT-cmW-lBhrwpwF4ymGdWRLouVdUW66CHZE/s1600/ISO+Standard+-+tanh+Function.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;173&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhrXCJrWSxTfjy6YBZBCbm48lreyG0tFKspwIVQ5a-1F9a1yDTzlUFM072eU7lA4kI2Pl7PpILL27gQWSOb8kwghT8X8btcM3iyZhgPY-U-QT-cmW-lBhrwpwF4ymGdWRLouVdUW66CHZE/s400/ISO+Standard+-+tanh+Function.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
The newest standard includes the &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;atanh&lt;/span&gt; function, but it is not implemented in Visual C++
2010; however, you can use the &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;log&lt;/span&gt;
function to determine the arc hyperbolic tangent.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&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/AVvXsEhNNH5I9RxVapQofPffyR2xjBoj242T84_VCdGG8sIBg-zI8qCIcxawH_Hr-WzhE2_Hsq3ibp-CLLHQ0BgpMcbnBQ7_fIq-ZemfiABrwDd85FKWgCpL7LQlfIlyz9UmIl-LMkP9lgJajtA/s1600/arc+hyperbolic+tan+function.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;232&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhNNH5I9RxVapQofPffyR2xjBoj242T84_VCdGG8sIBg-zI8qCIcxawH_Hr-WzhE2_Hsq3ibp-CLLHQ0BgpMcbnBQ7_fIq-ZemfiABrwDd85FKWgCpL7LQlfIlyz9UmIl-LMkP9lgJajtA/s400/arc+hyperbolic+tan+function.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&amp;nbsp;

&lt;br /&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;Test Code.&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
I tested the functions in Visual C++ 2010 as an console
application.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: green; font-family: Consolas;&quot;&gt;// The
standard library includes the system function.&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt; &lt;span style=&quot;color: #a31515;&quot;&gt;&amp;lt;cstdlib&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: green; font-family: Consolas;&quot;&gt;// C++
standard I/O library.&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt; &lt;span style=&quot;color: #a31515;&quot;&gt;&amp;lt;cstdio&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: green; font-family: Consolas;&quot;&gt;// C++
math library.&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt; &lt;span style=&quot;color: #a31515;&quot;&gt;&amp;lt;cmath&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt; main()&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Header.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;The
tanh Function in C &amp;amp; C++\n\n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;Given
x, any real number, the function returns y \n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;equal
to the hyperbolic tangent of x.\n\n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Counter for
loop.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; i;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Argument.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;double&lt;/span&gt; x;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Result.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;double&lt;/span&gt; y,
y2;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;&amp;nbsp;&amp;nbsp;&amp;nbsp; x&amp;nbsp;&amp;nbsp;
=&amp;gt;&amp;nbsp; tanh(x) = (exp(2*x) - 1.0)
/ (exp(2*x) + 1.0) \n\n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;for&lt;/span&gt; (i =
-5; i &amp;lt;= 5; ++i)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x = i * 1.0;&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; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; y = tanh(x);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; y2 = (exp(2*x) - 1.0) / (exp(2*x) +
1.0);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf (&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;%6.1f&amp;nbsp; =&amp;gt; %8.4f = %8.4f\n&quot;&lt;/span&gt;, x, y,
y2);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Keep console
window open.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; system(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;pause&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Return some
value.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt; 0;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;} &lt;span style=&quot;color: green;&quot;&gt;// end main&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;Output.&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&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/AVvXsEgVwCtVJg7tHPlI8bZI6W359G2YpX3e2UhlfrrPMHJqBQZTp8ifHinXdCMp8Hf8S47hk2MJhecZAezHaCs-N7k36E0APtyR0roTp6qIpNMmg3pLcypFA324Q2gqWhV2wiNGrFKKN3jP1W0/s1600/2012.03.17+-+LessonsInCoding+-+The+tanh+Function+in+C+%2526+C%252B%252B.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;203&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgVwCtVJg7tHPlI8bZI6W359G2YpX3e2UhlfrrPMHJqBQZTp8ifHinXdCMp8Hf8S47hk2MJhecZAezHaCs-N7k36E0APtyR0roTp6qIpNMmg3pLcypFA324Q2gqWhV2wiNGrFKKN3jP1W0/s400/2012.03.17+-+LessonsInCoding+-+The+tanh+Function+in+C+%2526+C%252B%252B.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lessonsincoding.blogspot.com/feeds/6325209702693376382/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://lessonsincoding.blogspot.com/2012/03/tanh-function-in-c-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5207350420173720706/posts/default/6325209702693376382'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5207350420173720706/posts/default/6325209702693376382'/><link rel='alternate' type='text/html' href='http://lessonsincoding.blogspot.com/2012/03/tanh-function-in-c-c.html' title='The tanh Function in C &amp; C++'/><author><name>James Piper</name><uri>http://www.blogger.com/profile/12387224587116087657</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGQ4ESUam_EJLtqp-f18iDIo2m7iCu_98TmJKP8if7vNZ76wasSEUxtnQLbxLqMcA2n9ozNH5PtbOy--l1i2r1znz7zBuCRwmXJOZCl1W_2WuKBPIJENOsjUnf27ltTw/s220/james_piper+sqr+image.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh-DkQu-6LkYD4h5cRTysmW-WhT4PWVcceGYavpPA4H6lUrC3n61tVExuMrMQwIOPXIJ1J9hWiLc9HAEet5gbD1WQlqeT4XpCQ6Js2wMOBH56IkH0jSX3YoZ0Gb9V00THGFPZOfZ3vd3P8/s72-c/tanh+Function.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5207350420173720706.post-9194429726639926983</id><published>2012-03-16T05:58:00.000-04:00</published><updated>2012-03-25T15:13:41.269-04:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C"/><category scheme="http://www.blogger.com/atom/ns#" term="C++"/><category scheme="http://www.blogger.com/atom/ns#" term="cmath library"/><title type='text'>The cosh Function in C &amp; C++</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
More functions from the&amp;nbsp;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;lt;math.h&amp;gt;&lt;/span&gt; or &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;lt;cmath&amp;gt;&lt;/span&gt; header files. Today it’s
about the &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;cosh&lt;/span&gt; function.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
The &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;cosh&lt;/span&gt;
function returns the hyperbolic cosine for any real number and is defined as
shown below.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&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/AVvXsEjvu7JrZ7-HEd-a_ukvJNxXGLq16bS5oTt4Thxbj8D_assMSqLEHb5qP2ojjtrt_JutcB75eekqEWFEf8dVuuTvDjuTvON9SZ8uB8F5WbADpRCcMCgmOJAX07SULvdCkorFCmUf3gSqYUM/s1600/cosh+Function.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;227&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjvu7JrZ7-HEd-a_ukvJNxXGLq16bS5oTt4Thxbj8D_assMSqLEHb5qP2ojjtrt_JutcB75eekqEWFEf8dVuuTvDjuTvON9SZ8uB8F5WbADpRCcMCgmOJAX07SULvdCkorFCmUf3gSqYUM/s400/cosh+Function.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&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/AVvXsEhV3Larf3aCzZkx1iCQYbaNL4P_5f89ukuEEYDVrkyz01fmjqcKjFq-H3Vo6Vaspr9Bi5Kx0QEGk-zhM33Lj6UdPNpq1v8KACQBz0K-5tJ-EDvo1FWT4eon_getKfaYLK9pJCBFMqF80AY/s1600/Hyperbolic+cosine+Curve.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;267&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhV3Larf3aCzZkx1iCQYbaNL4P_5f89ukuEEYDVrkyz01fmjqcKjFq-H3Vo6Vaspr9Bi5Kx0QEGk-zhM33Lj6UdPNpq1v8KACQBz0K-5tJ-EDvo1FWT4eon_getKfaYLK9pJCBFMqF80AY/s400/Hyperbolic+cosine+Curve.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
From C11 standard.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&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/AVvXsEhuTokbQc3lwxn2nXYSHAQH7GCuicGBL17hyMpGGlDkmDVhh0Y6vSu9Ymup9dGLMAmXNNV1x2oxpZlg_Una08zedKe6VzhgrK3z5T0P9O2GRzUP__RbcDQwZmpYYLmMMjYEjk5OOSFjMLk/s1600/ISO+Standard+-+cosh+Function.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;167&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhuTokbQc3lwxn2nXYSHAQH7GCuicGBL17hyMpGGlDkmDVhh0Y6vSu9Ymup9dGLMAmXNNV1x2oxpZlg_Una08zedKe6VzhgrK3z5T0P9O2GRzUP__RbcDQwZmpYYLmMMjYEjk5OOSFjMLk/s400/ISO+Standard+-+cosh+Function.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&amp;nbsp;

&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
The newest standard includes the &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;acosh&lt;/span&gt; function, but it is not implemented in Visual C++
2010; however, you can use the &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;log&lt;/span&gt;
function to determine the arc hyperbolic cosine.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&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/AVvXsEisq_Thyphenhyphen3EvVHg-YuhG5LA9FUvF3VsHsT2MRhVPKC8yRn9EK_2aLziPuzhE2ZBTxV14CmjpsgpmI0AZWZ23_2UyPK7-CVSRl0OTbadGfKlRdNEgbwGDLmODkHxTkGDcMz5GN50xzs5-Yb0/s1600/arc+hyperbolic+cos+function.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;220&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEisq_Thyphenhyphen3EvVHg-YuhG5LA9FUvF3VsHsT2MRhVPKC8yRn9EK_2aLziPuzhE2ZBTxV14CmjpsgpmI0AZWZ23_2UyPK7-CVSRl0OTbadGfKlRdNEgbwGDLmODkHxTkGDcMz5GN50xzs5-Yb0/s400/arc+hyperbolic+cos+function.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&amp;nbsp;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;Test Code.&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
I tested the functions in Visual C++ 2010 as an console
application.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: green; font-family: Consolas;&quot;&gt;// The
standard library includes the system function.&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt; &lt;span style=&quot;color: #a31515;&quot;&gt;&amp;lt;cstdlib&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: green; font-family: Consolas;&quot;&gt;// C++
standard I/O library.&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt; &lt;span style=&quot;color: #a31515;&quot;&gt;&amp;lt;cstdio&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: green; font-family: Consolas;&quot;&gt;// C++
math library.&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt; &lt;span style=&quot;color: #a31515;&quot;&gt;&amp;lt;cmath&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt; main()&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Header.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;The
cosh Function in C &amp;amp; C++\n\n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;Given
x, any real number, the function returns y \n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;equal
to the hyperbolic cosine of x.\n\n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Counter for
loop.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; i;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Argument.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;double&lt;/span&gt; x;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Result.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;double&lt;/span&gt; y,
y2;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;&amp;nbsp;&amp;nbsp;&amp;nbsp; x&amp;nbsp;&amp;nbsp;
=&amp;gt;&amp;nbsp; cosh(x) =&amp;nbsp; 0.5 * (exp(x) + 1.0/exp(x)) \n\n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;for&lt;/span&gt; (i =
-5; i &amp;lt;= 5; ++i)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x = i * 1.0;&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; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; y = cosh(x);&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; y2 = 0.5 * (exp(x) + 1.0/exp(x));&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf (&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;%6.1f&amp;nbsp; =&amp;gt; %8.4f = %8.4f\n&quot;&lt;/span&gt;, x, y,
y2);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Keep console
window open.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; system(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;pause&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Return some
value.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt; 0;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;} &lt;span style=&quot;color: green;&quot;&gt;// end main&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&amp;nbsp;

&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;Output.&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&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/AVvXsEhRfLlNoJ3GoIHlwROaFQtvLTPSs5HwX0-zTFq9oanHOewFDS4OkSH0K2RmodKySJq-ThmWR16amVcjJ_9F-0KlO0JyYu_F0D0Bp6L7CKorQQg-tmTcBVIpw-pNhwBeVKUisgxxWpLurjU/s1600/2012.03.16+-+LessonsInCoding+-+The+cosh+Function+in+C+&amp;amp;+C++.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;203&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhRfLlNoJ3GoIHlwROaFQtvLTPSs5HwX0-zTFq9oanHOewFDS4OkSH0K2RmodKySJq-ThmWR16amVcjJ_9F-0KlO0JyYu_F0D0Bp6L7CKorQQg-tmTcBVIpw-pNhwBeVKUisgxxWpLurjU/s400/2012.03.16+-+LessonsInCoding+-+The+cosh+Function+in+C+&amp;amp;+C++.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lessonsincoding.blogspot.com/feeds/9194429726639926983/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://lessonsincoding.blogspot.com/2012/03/cosh-function-in-c-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5207350420173720706/posts/default/9194429726639926983'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5207350420173720706/posts/default/9194429726639926983'/><link rel='alternate' type='text/html' href='http://lessonsincoding.blogspot.com/2012/03/cosh-function-in-c-c.html' title='The cosh Function in C &amp; C++'/><author><name>James Piper</name><uri>http://www.blogger.com/profile/12387224587116087657</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGQ4ESUam_EJLtqp-f18iDIo2m7iCu_98TmJKP8if7vNZ76wasSEUxtnQLbxLqMcA2n9ozNH5PtbOy--l1i2r1znz7zBuCRwmXJOZCl1W_2WuKBPIJENOsjUnf27ltTw/s220/james_piper+sqr+image.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjvu7JrZ7-HEd-a_ukvJNxXGLq16bS5oTt4Thxbj8D_assMSqLEHb5qP2ojjtrt_JutcB75eekqEWFEf8dVuuTvDjuTvON9SZ8uB8F5WbADpRCcMCgmOJAX07SULvdCkorFCmUf3gSqYUM/s72-c/cosh+Function.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5207350420173720706.post-7436325253604583039</id><published>2012-03-13T23:33:00.000-04:00</published><updated>2012-03-25T15:13:51.574-04:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C"/><category scheme="http://www.blogger.com/atom/ns#" term="C++"/><category scheme="http://www.blogger.com/atom/ns#" term="cmath library"/><title type='text'>The sinh Function in C &amp; C++</title><content type='html'>&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
More functions from the&amp;nbsp;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;lt;math.h&amp;gt;&lt;/span&gt; or &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;lt;cmath&amp;gt;&lt;/span&gt; header files. Today it’s
about the &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;sinh&lt;/span&gt; function.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
The &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;sinh&lt;/span&gt;
function returns the hyperbolic sine for any real number and is defined as
shown below.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&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/AVvXsEj4VpXlTA45uyqtvdoqUkfUxZgJ0Wk1zLupDikPFWE0uujSrApLpt9wqG08ARNf6AomcmkcZFz3MERDW-5sv4HIUQBHeCRzSwrj6dQxdXLjP_aIHV4XNcRZt16KmEUwoEHdOS-xgNvVId0/s1600/sinh+Function.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;331&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj4VpXlTA45uyqtvdoqUkfUxZgJ0Wk1zLupDikPFWE0uujSrApLpt9wqG08ARNf6AomcmkcZFz3MERDW-5sv4HIUQBHeCRzSwrj6dQxdXLjP_aIHV4XNcRZt16KmEUwoEHdOS-xgNvVId0/s400/sinh+Function.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&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/AVvXsEgoTiXmIx4KqqDnSeOBtvblY4cGbfpel-W15bVoH6xnAFVhsr08spO293jQLi22xjAcqth6vXw1LT-GvHUScYp6X8RDrYtzGTX9-mMd3UMxcPljDB4swfPyZ5y_yzQEZZ6MGGkOXhRpJxI/s1600/Hyperbolic+sine+Curve.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;271&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgoTiXmIx4KqqDnSeOBtvblY4cGbfpel-W15bVoH6xnAFVhsr08spO293jQLi22xjAcqth6vXw1LT-GvHUScYp6X8RDrYtzGTX9-mMd3UMxcPljDB4swfPyZ5y_yzQEZZ6MGGkOXhRpJxI/s400/Hyperbolic+sine+Curve.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;text-align: left;&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;text-align: left;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
From C11 standard.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&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/AVvXsEj5_Yh4YYrMeD0KZzeMv2mtda8Va56HZMVY3zxC3_JqW42jTvZ8Mm5HzhFEcAnvFbPMaxzlUedEPRmZvCQqz6bwK2G_CKNj5fJHL8EfPf7pvxIwOjSYL6QU_ad0sPVF83BMxcWZlHMml7Y/s1600/ISO+Standard+-+sinh+Function.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;183&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5_Yh4YYrMeD0KZzeMv2mtda8Va56HZMVY3zxC3_JqW42jTvZ8Mm5HzhFEcAnvFbPMaxzlUedEPRmZvCQqz6bwK2G_CKNj5fJHL8EfPf7pvxIwOjSYL6QU_ad0sPVF83BMxcWZlHMml7Y/s400/ISO+Standard+-+sinh+Function.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
The newest standard includes the &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;asinh&lt;/span&gt; function, but it is not implemented in Visual C++
2010; however, you can use the &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;log&lt;/span&gt;
function to determine the arc hyperbolic sine.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&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/AVvXsEhFIJbLkBT1woMtRje5GHOAJAMm7j_wzXQQpAaQcjlNuvlSpaZ-EehCrlF5jx17Y8iwJC-VJqRfH6Q_JTqNafSnw_ChzQ9rhcQdKQm-51XxVrqX_TqgzUOVVhjQT8OVgr_y9uVnb6KSIRo/s1600/arc+hyperbolic+sin+function.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;235&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhFIJbLkBT1woMtRje5GHOAJAMm7j_wzXQQpAaQcjlNuvlSpaZ-EehCrlF5jx17Y8iwJC-VJqRfH6Q_JTqNafSnw_ChzQ9rhcQdKQm-51XxVrqX_TqgzUOVVhjQT8OVgr_y9uVnb6KSIRo/s400/arc+hyperbolic+sin+function.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;Test Code.&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
I tested the functions in Visual C++ 2010 as an console
application.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: green; font-family: Consolas;&quot;&gt;// The
standard library includes the system function.&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt; &lt;span style=&quot;color: #a31515;&quot;&gt;&amp;lt;cstdlib&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: green; font-family: Consolas;&quot;&gt;// C++
standard I/O library.&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt; &lt;span style=&quot;color: #a31515;&quot;&gt;&amp;lt;cstdio&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: green; font-family: Consolas;&quot;&gt;// C++
math library.&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt; &lt;span style=&quot;color: #a31515;&quot;&gt;&amp;lt;cmath&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt; main()&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Header.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;The
sinh Function in C &amp;amp; C++\n\n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;Given
x, any real number, the function returns y \n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;equal
to the hyperbolic sine of x.\n\n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Counter for
loop.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; i;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Argument.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;double&lt;/span&gt; x;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: green;&quot;&gt;// Result.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;double&lt;/span&gt; y,
y2;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;&amp;nbsp;&amp;nbsp;&amp;nbsp; x&amp;nbsp;&amp;nbsp;
=&amp;gt;&amp;nbsp; sinh(x) =&amp;nbsp; 0.5 * (exp(x) - 1.0/exp(x)) \n\n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;for&lt;/span&gt; (i =
-5; i &amp;lt;= 5; ++i)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x = i * 1.0;&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; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; y = sinh(x);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; y2 = 0.5 * (exp(x) - 1.0/exp(x));&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf (&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;%6.1f&amp;nbsp; =&amp;gt; %8.4f = %8.4f\n&quot;&lt;/span&gt;, x, y,
y2);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Keep console
window open.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; system(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;pause&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Return some
value.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt; 0;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;} &lt;span style=&quot;color: green;&quot;&gt;// end main&lt;/span&gt;&lt;/span&gt; &lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;Output.&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&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/AVvXsEj5rVro_-fQqwOOuWFvwUIqVzKAL7-Dms5Z_QnD-EZF51CI11mbiFE46u_qLSA7wN4h3tMb71Id1KUyAmuJpbn4Su8lf2nnZhP-5kwcZ4lz7YQjagI-u0fvqzwSxENUOqRry7-HWQ-S9Xw/s1600/2012.03.13+-+LessonsInCoding+-+The+sinh+Function+in+C+%2526+C%252B%252B.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;203&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5rVro_-fQqwOOuWFvwUIqVzKAL7-Dms5Z_QnD-EZF51CI11mbiFE46u_qLSA7wN4h3tMb71Id1KUyAmuJpbn4Su8lf2nnZhP-5kwcZ4lz7YQjagI-u0fvqzwSxENUOqRry7-HWQ-S9Xw/s400/2012.03.13+-+LessonsInCoding+-+The+sinh+Function+in+C+%2526+C%252B%252B.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lessonsincoding.blogspot.com/feeds/7436325253604583039/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://lessonsincoding.blogspot.com/2012/03/sinh-function-in-c-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5207350420173720706/posts/default/7436325253604583039'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5207350420173720706/posts/default/7436325253604583039'/><link rel='alternate' type='text/html' href='http://lessonsincoding.blogspot.com/2012/03/sinh-function-in-c-c.html' title='The sinh Function in C &amp; C++'/><author><name>James Piper</name><uri>http://www.blogger.com/profile/12387224587116087657</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGQ4ESUam_EJLtqp-f18iDIo2m7iCu_98TmJKP8if7vNZ76wasSEUxtnQLbxLqMcA2n9ozNH5PtbOy--l1i2r1znz7zBuCRwmXJOZCl1W_2WuKBPIJENOsjUnf27ltTw/s220/james_piper+sqr+image.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj4VpXlTA45uyqtvdoqUkfUxZgJ0Wk1zLupDikPFWE0uujSrApLpt9wqG08ARNf6AomcmkcZFz3MERDW-5sv4HIUQBHeCRzSwrj6dQxdXLjP_aIHV4XNcRZt16KmEUwoEHdOS-xgNvVId0/s72-c/sinh+Function.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5207350420173720706.post-7422953990480728770</id><published>2012-03-13T05:32:00.000-04:00</published><updated>2012-03-25T15:14:01.355-04:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C"/><category scheme="http://www.blogger.com/atom/ns#" term="C++"/><category scheme="http://www.blogger.com/atom/ns#" term="cmath library"/><title type='text'>The sqrt Function in C &amp; C++</title><content type='html'>&lt;div class=&quot;eNoIndent&quot;&gt;
More functions from the&amp;nbsp;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;lt;math.h&amp;gt;&lt;/span&gt; or &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;lt;cmath&amp;gt;&lt;/span&gt; header files. Today it’s
about the &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;sqrt&lt;/span&gt; function.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
The &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;sqrt&lt;/span&gt;
function is straightforward. Given values for x, the function returns y, the
square root.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
From C11 standard.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&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/AVvXsEgdhY2XSP1UJyhk_TQyxQvjHEB6shrXEI886hlW3K8vZe3D1iSrDQjoCgpbPBdtv-l32zwXw_A3QeWe8GIanzExbl0Rl46Km23m8BQUCUpXt-YZtR7-U1vV6LnnhyphenhyphencvCyMTMYi4bcRlPo0/s1600/ISO+Standard+-+sqrt+Function.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;173&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgdhY2XSP1UJyhk_TQyxQvjHEB6shrXEI886hlW3K8vZe3D1iSrDQjoCgpbPBdtv-l32zwXw_A3QeWe8GIanzExbl0Rl46Km23m8BQUCUpXt-YZtR7-U1vV6LnnhyphenhyphencvCyMTMYi4bcRlPo0/s400/ISO+Standard+-+sqrt+Function.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;Test Code.&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
I tested the functions in Visual C++ 2010 as an console
application.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: green; font-family: Consolas;&quot;&gt;// The
standard library includes the system function.&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt; &lt;span style=&quot;color: #a31515;&quot;&gt;&amp;lt;cstdlib&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: green; font-family: Consolas;&quot;&gt;// C++
standard I/O library.&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt; &lt;span style=&quot;color: #a31515;&quot;&gt;&amp;lt;cstdio&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: green; font-family: Consolas;&quot;&gt;// C++
math library.&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt; &lt;span style=&quot;color: #a31515;&quot;&gt;&amp;lt;cmath&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt; main()&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Header.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;The
sqrt Function in C &amp;amp; C++\n\n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;Given
x, the function returns y equal to the square root of x.\n\n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Counter for
loop.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; i;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Argument.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;double&lt;/span&gt; n;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Result.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;double&lt;/span&gt; y;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;&amp;nbsp; y&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
x&amp;nbsp;&amp;nbsp;&amp;nbsp; y&amp;nbsp;&amp;nbsp;&amp;nbsp; =&amp;nbsp;&amp;nbsp;
x\n\n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;for&lt;/span&gt; (i = 1;
i &amp;lt; 10; ++i)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; n = 12.3456 / i;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; y = sqrt(n);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf (&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;%5.4f&amp;nbsp; x %5.4f = %6.4f\n&quot;&lt;/span&gt;, y, y, n);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Keep console
window open.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; system(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;pause&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Return some
value.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt; 0;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;} &lt;span style=&quot;color: green;&quot;&gt;// end main&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;Output.&lt;/b&gt;&lt;/div&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/AVvXsEisg1dHPpiO4VG6Beu2LhOn_cu_qNZkZi8Xdxky1Ew5h2bTEhkOzrudCj4rFtQXUcaBbkj7hmthmnsc7BvyS2e5EcCtd07XC0_28fimkGKc8whaaIfvYqm2dV6Z9VRbgBM9Mw4c3AzgAR8/s1600/2012.03.13+-+LessonsInCoding+-+The+sqrt+Function+in+C+%2526+C%252B%252B.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;210&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEisg1dHPpiO4VG6Beu2LhOn_cu_qNZkZi8Xdxky1Ew5h2bTEhkOzrudCj4rFtQXUcaBbkj7hmthmnsc7BvyS2e5EcCtd07XC0_28fimkGKc8whaaIfvYqm2dV6Z9VRbgBM9Mw4c3AzgAR8/s400/2012.03.13+-+LessonsInCoding+-+The+sqrt+Function+in+C+%2526+C%252B%252B.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lessonsincoding.blogspot.com/feeds/7422953990480728770/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://lessonsincoding.blogspot.com/2012/03/sqrt-function-in-c-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5207350420173720706/posts/default/7422953990480728770'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5207350420173720706/posts/default/7422953990480728770'/><link rel='alternate' type='text/html' href='http://lessonsincoding.blogspot.com/2012/03/sqrt-function-in-c-c.html' title='The sqrt Function in C &amp; C++'/><author><name>James Piper</name><uri>http://www.blogger.com/profile/12387224587116087657</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGQ4ESUam_EJLtqp-f18iDIo2m7iCu_98TmJKP8if7vNZ76wasSEUxtnQLbxLqMcA2n9ozNH5PtbOy--l1i2r1znz7zBuCRwmXJOZCl1W_2WuKBPIJENOsjUnf27ltTw/s220/james_piper+sqr+image.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgdhY2XSP1UJyhk_TQyxQvjHEB6shrXEI886hlW3K8vZe3D1iSrDQjoCgpbPBdtv-l32zwXw_A3QeWe8GIanzExbl0Rl46Km23m8BQUCUpXt-YZtR7-U1vV6LnnhyphenhyphencvCyMTMYi4bcRlPo0/s72-c/ISO+Standard+-+sqrt+Function.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5207350420173720706.post-6990304290204666482</id><published>2012-03-12T03:22:00.000-04:00</published><updated>2012-03-25T15:14:14.119-04:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C"/><category scheme="http://www.blogger.com/atom/ns#" term="C++"/><category scheme="http://www.blogger.com/atom/ns#" term="cmath library"/><title type='text'>The pow Function in C &amp; C++</title><content type='html'>&lt;br /&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
More functions from the&amp;nbsp;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;lt;math.h&amp;gt;&lt;/span&gt; or &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;lt;cmath&amp;gt;&lt;/span&gt; header files. Today it’s
about the &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;pow&lt;/span&gt; function.&lt;/div&gt;
&amp;nbsp;

&lt;br /&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
The &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;pow&lt;/span&gt;
function is straightforward. Given values for x and n, the function returns x
to the nth power.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
From C11 standard.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&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/AVvXsEhIeSKBWlRb_ep09aPTbbTaluDGej1nJjrWTr_OqDG33TaUrWzOEPratKrruYeTNYVwZc8JQDjskDNVFmIJzKV2zlhbNWRT3Euk6HAuJlVx-e7lgJRK4tzAhxMFQa35X8_PgeRn_5iZqic/s1600/ISO+Standard+-+pow+Function.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;195&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhIeSKBWlRb_ep09aPTbbTaluDGej1nJjrWTr_OqDG33TaUrWzOEPratKrruYeTNYVwZc8JQDjskDNVFmIJzKV2zlhbNWRT3Euk6HAuJlVx-e7lgJRK4tzAhxMFQa35X8_PgeRn_5iZqic/s400/ISO+Standard+-+pow+Function.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&amp;nbsp;

&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;Test Code.&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
I tested the functions in Visual C++ 2010 as an console
application.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: green; font-family: Consolas;&quot;&gt;// The
standard library includes the system function.&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt; &lt;span style=&quot;color: #a31515;&quot;&gt;&amp;lt;cstdlib&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: green; font-family: Consolas;&quot;&gt;// C++
standard I/O library.&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt; &lt;span style=&quot;color: #a31515;&quot;&gt;&amp;lt;cstdio&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: green; font-family: Consolas;&quot;&gt;// C++
math library.&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt; &lt;span style=&quot;color: #a31515;&quot;&gt;&amp;lt;cmath&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt; main()&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Header.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;The
pow Function in C &amp;amp; C++\n\n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;Given
x and n, the function returns x to the nth power.\n\n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Counter for
loop.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; i;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Argument.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;double&lt;/span&gt; x,
n;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Result.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;double&lt;/span&gt; y;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;
y&amp;nbsp;&amp;nbsp;&amp;nbsp; =&amp;nbsp;&amp;nbsp;&amp;nbsp;
x&amp;nbsp;&amp;nbsp; ^ n\n\n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;for&lt;/span&gt; (i = 1;
i &amp;lt; 10; ++i)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x = 12.3456 / i;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; n = i;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; y = pow(x, n);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf (&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;%5.2f
= %6.3f ^ %1.0f\n&quot;&lt;/span&gt;, y, x, n);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Keep console
window open.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; system(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;pause&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Return some
value.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt; 0;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;} &lt;span style=&quot;color: green;&quot;&gt;// end main&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;Output.&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&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/AVvXsEjZifYUQ9tw0H5ch8zKm8b8bXzOipmufFRSjQPV5yWzm6jDvvip8saZBQZA0KboHd7SaJu8VFyzDogDFgebnQGcXLwa1Kj__k2Br-rdSSC93pS1pVwdTAZAaLSXA6lk5eTJpyErb5NWvUg/s1600/2012.03.12+-+LessonsInCoding+-+The+pow+Function+in+C+%2526+C%252B%252B.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;206&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZifYUQ9tw0H5ch8zKm8b8bXzOipmufFRSjQPV5yWzm6jDvvip8saZBQZA0KboHd7SaJu8VFyzDogDFgebnQGcXLwa1Kj__k2Br-rdSSC93pS1pVwdTAZAaLSXA6lk5eTJpyErb5NWvUg/s400/2012.03.12+-+LessonsInCoding+-+The+pow+Function+in+C+%2526+C%252B%252B.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lessonsincoding.blogspot.com/feeds/6990304290204666482/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://lessonsincoding.blogspot.com/2012/03/pow-function-in-c-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5207350420173720706/posts/default/6990304290204666482'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5207350420173720706/posts/default/6990304290204666482'/><link rel='alternate' type='text/html' href='http://lessonsincoding.blogspot.com/2012/03/pow-function-in-c-c.html' title='The pow Function in C &amp; C++'/><author><name>James Piper</name><uri>http://www.blogger.com/profile/12387224587116087657</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGQ4ESUam_EJLtqp-f18iDIo2m7iCu_98TmJKP8if7vNZ76wasSEUxtnQLbxLqMcA2n9ozNH5PtbOy--l1i2r1znz7zBuCRwmXJOZCl1W_2WuKBPIJENOsjUnf27ltTw/s220/james_piper+sqr+image.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhIeSKBWlRb_ep09aPTbbTaluDGej1nJjrWTr_OqDG33TaUrWzOEPratKrruYeTNYVwZc8JQDjskDNVFmIJzKV2zlhbNWRT3Euk6HAuJlVx-e7lgJRK4tzAhxMFQa35X8_PgeRn_5iZqic/s72-c/ISO+Standard+-+pow+Function.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5207350420173720706.post-6034807614227171208</id><published>2012-03-11T11:33:00.000-04:00</published><updated>2012-03-25T15:14:36.551-04:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C"/><category scheme="http://www.blogger.com/atom/ns#" term="C++"/><category scheme="http://www.blogger.com/atom/ns#" term="cmath library"/><title type='text'>The frexp Function in C &amp; C++</title><content type='html'>&lt;br /&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
More functions from the&amp;nbsp;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;lt;math.h&amp;gt;&lt;/span&gt; or &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;lt;cmath&amp;gt;&lt;/span&gt; header files. Today it’s
about the &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;frexp&lt;/span&gt; function.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
Given a floating point value a, the function returns S and n
such that a = S x 2&lt;sup&gt;n&lt;/sup&gt;.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
The value of S is limited to a range of greater than or equal
to 0.5 and less than 1.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
The value of n is an integer and is returned by way of a
pointer.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&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/AVvXsEiMY5tFbxMAKXSRlqGPEyJXw3X2waNEHjX_uQe34bxpr6slj1XGauWsLzQ6I2yHa8SYrbVf4NDKn9MfG7njcYHKXWwUCNjE9HftbRrrgvdGaKqsSCo4gizUZLeEzDh8RgnZ6wAq71p8TGo/s1600/The+frexp+Function.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;326&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMY5tFbxMAKXSRlqGPEyJXw3X2waNEHjX_uQe34bxpr6slj1XGauWsLzQ6I2yHa8SYrbVf4NDKn9MfG7njcYHKXWwUCNjE9HftbRrrgvdGaKqsSCo4gizUZLeEzDh8RgnZ6wAq71p8TGo/s400/The+frexp+Function.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
From C11 standard.&lt;/div&gt;
&lt;br /&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/AVvXsEgk8-14SPIi99WZg1qJNjHn-1Jfh51uzDu9jjieAZeMn94rw_9uvCxYchU8PyOrDoY8E6yAe8nRfpeBHMFUhwCzvULGRQgXOzfGBTj5CHpmCqkIPpjc3Zh29-pJJfH7aK6uhL1mxlJMzsM/s1600/ISO+Standard+-+frexp+Function.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;212&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgk8-14SPIi99WZg1qJNjHn-1Jfh51uzDu9jjieAZeMn94rw_9uvCxYchU8PyOrDoY8E6yAe8nRfpeBHMFUhwCzvULGRQgXOzfGBTj5CHpmCqkIPpjc3Zh29-pJJfH7aK6uhL1mxlJMzsM/s400/ISO+Standard+-+frexp+Function.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;Test Code.&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
I tested the functions in Visual C++ 2010 as an console
application.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: green; font-family: Consolas;&quot;&gt;// The
standard library includes the system function.&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt; &lt;span style=&quot;color: #a31515;&quot;&gt;&amp;lt;cstdlib&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: green; font-family: Consolas;&quot;&gt;// C++
standard I/O library.&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt; &lt;span style=&quot;color: #a31515;&quot;&gt;&amp;lt;cstdio&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: green; font-family: Consolas;&quot;&gt;// C++
math library.&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt; &lt;span style=&quot;color: #a31515;&quot;&gt;&amp;lt;cmath&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt; main()&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Header.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;The
frexp Function in C &amp;amp; C++\n\n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;Given
a, the function returns S and n\n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;such
that a&amp;nbsp; = S x 2 to the nth
power.\n\n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Counter for
loop.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; i;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Return value,
significant.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;double&lt;/span&gt; S;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Arugment.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;double&lt;/span&gt; a;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// 2 to the Nth
power.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; n = 0;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;a&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; =&amp;nbsp;&amp;nbsp;
S&amp;nbsp;&amp;nbsp; x 2 ^ n\n\n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;for&lt;/span&gt; (i =
10; i &amp;lt; 27; ++i)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; a = i / 10.0;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; S = frexp(a, &amp;amp;n);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf (&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;%4.3f
= %4.3f x 2 ^ %d\n&quot;&lt;/span&gt;, a, S, n);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Keep console
window open.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; system(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;pause&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Return some
value.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt; 0;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;} &lt;span style=&quot;color: green;&quot;&gt;// end main&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&amp;nbsp; &lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;Output.&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&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/AVvXsEgzqSYzz6WflBbP8T8Y7npb4cqXCqHuy8MJ6eddOr5gxmqXdUAKw3yZtEOMBes6jJ4LWZPmdw_Eio6ky5TtGUpyjRV5fatyKabHHaBqMwwEPpmCeqGRtF3AJqQHe61jrazgZcK9JAmcy9o/s1600/2012.03.11+-+LessonsInCoding+-+The+frexp+Function+in+C+%2526+C%252B%252B.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;205&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgzqSYzz6WflBbP8T8Y7npb4cqXCqHuy8MJ6eddOr5gxmqXdUAKw3yZtEOMBes6jJ4LWZPmdw_Eio6ky5TtGUpyjRV5fatyKabHHaBqMwwEPpmCeqGRtF3AJqQHe61jrazgZcK9JAmcy9o/s400/2012.03.11+-+LessonsInCoding+-+The+frexp+Function+in+C+%2526+C%252B%252B.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lessonsincoding.blogspot.com/feeds/6034807614227171208/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://lessonsincoding.blogspot.com/2012/03/frexp-function-in-c-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5207350420173720706/posts/default/6034807614227171208'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5207350420173720706/posts/default/6034807614227171208'/><link rel='alternate' type='text/html' href='http://lessonsincoding.blogspot.com/2012/03/frexp-function-in-c-c.html' title='The frexp Function in C &amp; C++'/><author><name>James Piper</name><uri>http://www.blogger.com/profile/12387224587116087657</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGQ4ESUam_EJLtqp-f18iDIo2m7iCu_98TmJKP8if7vNZ76wasSEUxtnQLbxLqMcA2n9ozNH5PtbOy--l1i2r1znz7zBuCRwmXJOZCl1W_2WuKBPIJENOsjUnf27ltTw/s220/james_piper+sqr+image.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMY5tFbxMAKXSRlqGPEyJXw3X2waNEHjX_uQe34bxpr6slj1XGauWsLzQ6I2yHa8SYrbVf4NDKn9MfG7njcYHKXWwUCNjE9HftbRrrgvdGaKqsSCo4gizUZLeEzDh8RgnZ6wAq71p8TGo/s72-c/The+frexp+Function.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5207350420173720706.post-6842178836409559021</id><published>2012-03-09T21:34:00.000-05:00</published><updated>2012-03-25T15:14:58.708-04:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C"/><category scheme="http://www.blogger.com/atom/ns#" term="C++"/><category scheme="http://www.blogger.com/atom/ns#" term="cmath library"/><title type='text'>The ldexp Function in C &amp; C++</title><content type='html'>&lt;br /&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
More functions from the&amp;nbsp;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;lt;math.h&amp;gt;&lt;/span&gt; or &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;lt;cmath&amp;gt;&lt;/span&gt; header files. Today it’s
about the &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;ldexp&lt;/span&gt; function.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
Given two values for a and n, the function returns y such
that y = a x 2&lt;sup&gt;n&lt;/sup&gt;.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&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/AVvXsEgER7vu1vAmotyKt6JPk-iRNn1S9nYeuTQ9LeKJNotiMYAFYGcZMRM7a_ZDObo8kFtbXKHauPFmPWtvcWy8pSC0VssXf0bQWq3kuBDnu6FTRNCMQfewLxcboyrmM5rkmJaWG_MXueqyC7A/s1600/The+ldexp+Function.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;348&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgER7vu1vAmotyKt6JPk-iRNn1S9nYeuTQ9LeKJNotiMYAFYGcZMRM7a_ZDObo8kFtbXKHauPFmPWtvcWy8pSC0VssXf0bQWq3kuBDnu6FTRNCMQfewLxcboyrmM5rkmJaWG_MXueqyC7A/s400/The+ldexp+Function.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
From C11 standard.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&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/AVvXsEgDdDI4e4y4fXl1QvAtzK6Tff683ASnUx9Kp0EmTFsQZFPy7spbjVk_Rl-tkBxwuVRyvQqf1FU2zPcM4MBl85uhyhtjjEmFs4kzseBXyVLFCKLvO9bCDlVkrfOo-ehyfUAAIqEFD-NV_ag/s1600/ISO+Standard+-+ldexp+Function.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;167&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDdDI4e4y4fXl1QvAtzK6Tff683ASnUx9Kp0EmTFsQZFPy7spbjVk_Rl-tkBxwuVRyvQqf1FU2zPcM4MBl85uhyhtjjEmFs4kzseBXyVLFCKLvO9bCDlVkrfOo-ehyfUAAIqEFD-NV_ag/s400/ISO+Standard+-+ldexp+Function.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;Test Code.&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
I tested the functions in Visual C++ 2010 as an console
application.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: green; font-family: Consolas;&quot;&gt;// The
standard library includes the system function.&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt; &lt;span style=&quot;color: #a31515;&quot;&gt;&amp;lt;cstdlib&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: green; font-family: Consolas;&quot;&gt;// C++
standard I/O library.&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt; &lt;span style=&quot;color: #a31515;&quot;&gt;&amp;lt;cstdio&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: green; font-family: Consolas;&quot;&gt;// C++
math library.&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt; &lt;span style=&quot;color: #a31515;&quot;&gt;&amp;lt;cmath&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt; main()&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;{ &lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Header.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;The
ldexp Function in C &amp;amp; C++\n\n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;Given
a and n, the function returns\n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;a
x 2 to the nth power.\n\n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; i;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot; a
x 2 ^&amp;nbsp; n\n\n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;for&lt;/span&gt; (i = 0;
i &amp;lt; 16; ++i)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;10
x 2 ^ %2d = %8.2f\n&quot;&lt;/span&gt;, i, ldexp(10.0, i));&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Keep console
window open.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; system(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;pause&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Return some
value.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt; 0;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;} &lt;span style=&quot;color: green;&quot;&gt;// end main&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;Output.&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&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/AVvXsEiUll2jzJB_Zqu20qH9CJ_rQcSEcrjoCJLjZH9tG0amDm3azcPYoMB0lx__ukSLo01_loQHgWJZRjieaSOpyziLmMzs2iEapSG3CYKpNXGAAFvAQrhzsiNgmXKBafgDxQvt5MT37_Du1Ms/s1600/2012.03.09+-+LessonsInCoding+-+The+ldexp+Function+in+C+&amp;amp;+C++.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;207&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiUll2jzJB_Zqu20qH9CJ_rQcSEcrjoCJLjZH9tG0amDm3azcPYoMB0lx__ukSLo01_loQHgWJZRjieaSOpyziLmMzs2iEapSG3CYKpNXGAAFvAQrhzsiNgmXKBafgDxQvt5MT37_Du1Ms/s400/2012.03.09+-+LessonsInCoding+-+The+ldexp+Function+in+C+&amp;amp;+C++.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lessonsincoding.blogspot.com/feeds/6842178836409559021/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://lessonsincoding.blogspot.com/2012/03/ldexp-function-in-c-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5207350420173720706/posts/default/6842178836409559021'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5207350420173720706/posts/default/6842178836409559021'/><link rel='alternate' type='text/html' href='http://lessonsincoding.blogspot.com/2012/03/ldexp-function-in-c-c.html' title='The ldexp Function in C &amp; C++'/><author><name>James Piper</name><uri>http://www.blogger.com/profile/12387224587116087657</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGQ4ESUam_EJLtqp-f18iDIo2m7iCu_98TmJKP8if7vNZ76wasSEUxtnQLbxLqMcA2n9ozNH5PtbOy--l1i2r1znz7zBuCRwmXJOZCl1W_2WuKBPIJENOsjUnf27ltTw/s220/james_piper+sqr+image.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgER7vu1vAmotyKt6JPk-iRNn1S9nYeuTQ9LeKJNotiMYAFYGcZMRM7a_ZDObo8kFtbXKHauPFmPWtvcWy8pSC0VssXf0bQWq3kuBDnu6FTRNCMQfewLxcboyrmM5rkmJaWG_MXueqyC7A/s72-c/The+ldexp+Function.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5207350420173720706.post-1787099023723567210</id><published>2012-03-09T04:40:00.000-05:00</published><updated>2012-03-25T15:15:27.722-04:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C"/><category scheme="http://www.blogger.com/atom/ns#" term="C++"/><category scheme="http://www.blogger.com/atom/ns#" term="cmath library"/><title type='text'>The fmod Function in C &amp; C++</title><content type='html'>&lt;br /&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
More functions from the&amp;nbsp;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;lt;math.h&amp;gt;&lt;/span&gt; or &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;lt;cmath&amp;gt;&lt;/span&gt; header files. Today it’s
about the f&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;mod&lt;/span&gt; function.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
The modulus operator, %, returns the remainder of a over b.
For example, &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;5
% 2 = 1&lt;/span&gt; since 4, a multiple of 2, plus 1, the remainder, equals 5. The
modulus operator however can only be used with whole numbers. The &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;fmod&lt;/span&gt;
function applies the same principle to floating-point numbers.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&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/AVvXsEhRj8r61gC7bqCg7aiEx2ErvQTBs5-5zPMqUBhnyeL0EiJuYTi3fVnNurgcu3zaC7pWMqparqpyQXlZJF03qTZ5vKCEQHnZZf9sysjtuCM5qZiAmyCjuRgZAvw4BIyXxd7nX9hl-eZx7HU/s1600/fmod+Function.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhRj8r61gC7bqCg7aiEx2ErvQTBs5-5zPMqUBhnyeL0EiJuYTi3fVnNurgcu3zaC7pWMqparqpyQXlZJF03qTZ5vKCEQHnZZf9sysjtuCM5qZiAmyCjuRgZAvw4BIyXxd7nX9hl-eZx7HU/s400/fmod+Function.jpg&quot; width=&quot;375&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&amp;nbsp;

&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
From C11 standard.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&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/AVvXsEh6K3gQYp-9GOKhewJJSPY0_ns4bLo7FzvaMpwWOZ4bETf_wlOQgcocS1swtiq83s_BT4YNoTao0O0zcUlGbw7bEjFrDqUBk00W2NwwoMhyphenhyphenuo0k0-tSpKugvFmz_mTl_6If1skZGlAmvXc/s1600/ISO+Standard+-+fmod+Function.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;178&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh6K3gQYp-9GOKhewJJSPY0_ns4bLo7FzvaMpwWOZ4bETf_wlOQgcocS1swtiq83s_BT4YNoTao0O0zcUlGbw7bEjFrDqUBk00W2NwwoMhyphenhyphenuo0k0-tSpKugvFmz_mTl_6If1skZGlAmvXc/s400/ISO+Standard+-+fmod+Function.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&amp;nbsp;

&lt;br /&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;Test Code.&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
I tested the functions in Visual C++ 2010 as an console
application.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: green; font-family: Consolas;&quot;&gt;// The
standard library includes the system function.&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt; &lt;span style=&quot;color: #a31515;&quot;&gt;&amp;lt;cstdlib&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: green; font-family: Consolas;&quot;&gt;// C++
standard I/O library.&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt; &lt;span style=&quot;color: #a31515;&quot;&gt;&amp;lt;cstdio&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: green; font-family: Consolas;&quot;&gt;// C++ math
library.&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt; &lt;span style=&quot;color: #a31515;&quot;&gt;&amp;lt;cmath&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt; main()&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Header.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;fmod
Function\n\n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;x
= fmod(a,b) \n\n\n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;Integer
Modulus\n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;5
%% 2 = %d&quot;&lt;/span&gt;, 5 % 2);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;\n\nFloating-point
Modulus\n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;modf(5.3,
2) = %6.3f\t&quot;&lt;/span&gt;, fmod(5.3, 2.0));&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;\n\n&quot;&lt;/span&gt;);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Keep console
window open.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; system(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;pause&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Return some
value.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt; 0;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;} &lt;span style=&quot;color: green;&quot;&gt;// end main&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;Output.&lt;/b&gt;&lt;/div&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/AVvXsEhdzVw0ZxtlMwKsIxf45Ocde1sJbAciaFEGFsAezmYXGCK-0h72IP-qDFNt5MyUUaBqNHu34K9jXUaNIqFrIzeQ_6cOkC0g_RJWlQE6DGlhnjGUwiyNBpRYAaSPIGflgUpYeiFjH6W3a_c/s1600/2012.03.08+-+LessonsInCoding+-+The+fmod+Function+in+C+&amp;amp;+C++.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;206&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhdzVw0ZxtlMwKsIxf45Ocde1sJbAciaFEGFsAezmYXGCK-0h72IP-qDFNt5MyUUaBqNHu34K9jXUaNIqFrIzeQ_6cOkC0g_RJWlQE6DGlhnjGUwiyNBpRYAaSPIGflgUpYeiFjH6W3a_c/s400/2012.03.08+-+LessonsInCoding+-+The+fmod+Function+in+C+&amp;amp;+C++.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://lessonsincoding.blogspot.com/feeds/1787099023723567210/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://lessonsincoding.blogspot.com/2012/03/fmod-function-in-c-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5207350420173720706/posts/default/1787099023723567210'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5207350420173720706/posts/default/1787099023723567210'/><link rel='alternate' type='text/html' href='http://lessonsincoding.blogspot.com/2012/03/fmod-function-in-c-c.html' title='The fmod Function in C &amp; C++'/><author><name>James Piper</name><uri>http://www.blogger.com/profile/12387224587116087657</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGQ4ESUam_EJLtqp-f18iDIo2m7iCu_98TmJKP8if7vNZ76wasSEUxtnQLbxLqMcA2n9ozNH5PtbOy--l1i2r1znz7zBuCRwmXJOZCl1W_2WuKBPIJENOsjUnf27ltTw/s220/james_piper+sqr+image.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhRj8r61gC7bqCg7aiEx2ErvQTBs5-5zPMqUBhnyeL0EiJuYTi3fVnNurgcu3zaC7pWMqparqpyQXlZJF03qTZ5vKCEQHnZZf9sysjtuCM5qZiAmyCjuRgZAvw4BIyXxd7nX9hl-eZx7HU/s72-c/fmod+Function.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5207350420173720706.post-5588310344246736816</id><published>2012-03-09T02:06:00.000-05:00</published><updated>2012-03-25T15:15:57.151-04:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C"/><category scheme="http://www.blogger.com/atom/ns#" term="C++"/><category scheme="http://www.blogger.com/atom/ns#" term="cmath library"/><title type='text'>The modf Function in C &amp; C++</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
More functions from the&amp;nbsp;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;lt;math.h&amp;gt;&lt;/span&gt; or &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;lt;cmath&amp;gt;&lt;/span&gt; header files. Today it’s
about the &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;modf&lt;/span&gt; function.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
This function returns two values. To do that, one part is
returned by way of assignment (e.g., R1 = fn). The second part is return by
storing the value in the second argument. (e.g., R1 = f(a,R2). It accomplishes
this by using pointers.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
The &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;modf&lt;/span&gt;
function takes a floating point number, e.g., a.b, and breaks the two apart
such that R1 = b and R2 = a. R2 is the fractional part. R1 is the integral
part.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&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/AVvXsEib1RS75i-JwHKOeYW37lR_eeAq4fVw8-z9SDicTPHhDiMiMROIGa0XjFvlsrYnim5NLbe4Fe7vrAR6W2ArQy4oAux-n_huW0plOUL4Qeqwaypm5Ow_GZ4dcolhkjMp46iqcZXWlwA_oT8/s1600/modf+Function.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;341&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEib1RS75i-JwHKOeYW37lR_eeAq4fVw8-z9SDicTPHhDiMiMROIGa0XjFvlsrYnim5NLbe4Fe7vrAR6W2ArQy4oAux-n_huW0plOUL4Qeqwaypm5Ow_GZ4dcolhkjMp46iqcZXWlwA_oT8/s400/modf+Function.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
From C11 standard.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&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/AVvXsEh1cXh0zmXVOiiQOmO25_5eAsYfEmEKH4xhJWcAyyQW-2ZiAXT6NXBB-KpScJj3nN7b0HwLL9XXNPGAnBHOv-5KtlBB9XLNnCk4fYoA1ofQc5I-l01alYRkWMMTq6JzQgu-dlDkNwGxHMI/s1600/ISO+Standard+-+modf+Function.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;192&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1cXh0zmXVOiiQOmO25_5eAsYfEmEKH4xhJWcAyyQW-2ZiAXT6NXBB-KpScJj3nN7b0HwLL9XXNPGAnBHOv-5KtlBB9XLNnCk4fYoA1ofQc5I-l01alYRkWMMTq6JzQgu-dlDkNwGxHMI/s400/ISO+Standard+-+modf+Function.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: green; font-family: Consolas;&quot;&gt;// The
standard library includes the system function.&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt; &lt;span style=&quot;color: #a31515;&quot;&gt;&amp;lt;cstdlib&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: green; font-family: Consolas;&quot;&gt;// C++
standard I/O library.&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt; &lt;span style=&quot;color: #a31515;&quot;&gt;&amp;lt;cstdio&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: green; font-family: Consolas;&quot;&gt;// C++
math library.&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt; &lt;span style=&quot;color: #a31515;&quot;&gt;&amp;lt;cmath&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt; main()&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Header.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;modf
Function\n\n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;R1
= modf(a,R2) \n\n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;double&lt;/span&gt; R1,
R2;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;double&lt;/span&gt; a =
123.456;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; R1 = modf(a, &amp;amp;R2);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;a
= 123.456 R1 = %6.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a31515; font-family: Consolas; font-size: 12pt;&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;f\tR2 = %3.f\n\n&quot;&lt;/span&gt;, R1, R2);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Keep console
window open.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; system(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;pause&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Return some
value.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt; 0;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;} &lt;span style=&quot;color: green;&quot;&gt;// end main&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&amp;nbsp;

&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;Output.&lt;/b&gt; &lt;/div&gt;
&lt;br /&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/AVvXsEjhF8_Mm9-84YFCN6Oa0o2_DyBrtDP-e7gp41Gu83Nzh79uiuD1iCPxx45qply4gB1JR2sfKia-7mys3wrMiPLTO5S36X11RkVnlMvQ9BZPxmCoMNu8jZhtyO5RvvOWncYfbqBcPb4EuEQ/s1600/2012.03.08+-+LessonsInCoding+-+The+modf+Function+in+C+%2526+C%252B%252B.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;205&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhF8_Mm9-84YFCN6Oa0o2_DyBrtDP-e7gp41Gu83Nzh79uiuD1iCPxx45qply4gB1JR2sfKia-7mys3wrMiPLTO5S36X11RkVnlMvQ9BZPxmCoMNu8jZhtyO5RvvOWncYfbqBcPb4EuEQ/s400/2012.03.08+-+LessonsInCoding+-+The+modf+Function+in+C+%2526+C%252B%252B.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lessonsincoding.blogspot.com/feeds/5588310344246736816/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://lessonsincoding.blogspot.com/2012/03/modf-function-in-c-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5207350420173720706/posts/default/5588310344246736816'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5207350420173720706/posts/default/5588310344246736816'/><link rel='alternate' type='text/html' href='http://lessonsincoding.blogspot.com/2012/03/modf-function-in-c-c.html' title='The modf Function in C &amp; C++'/><author><name>James Piper</name><uri>http://www.blogger.com/profile/12387224587116087657</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGQ4ESUam_EJLtqp-f18iDIo2m7iCu_98TmJKP8if7vNZ76wasSEUxtnQLbxLqMcA2n9ozNH5PtbOy--l1i2r1znz7zBuCRwmXJOZCl1W_2WuKBPIJENOsjUnf27ltTw/s220/james_piper+sqr+image.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEib1RS75i-JwHKOeYW37lR_eeAq4fVw8-z9SDicTPHhDiMiMROIGa0XjFvlsrYnim5NLbe4Fe7vrAR6W2ArQy4oAux-n_huW0plOUL4Qeqwaypm5Ow_GZ4dcolhkjMp46iqcZXWlwA_oT8/s72-c/modf+Function.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5207350420173720706.post-2787752970977020381</id><published>2012-03-06T20:35:00.000-05:00</published><updated>2012-03-25T15:11:19.090-04:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C"/><category scheme="http://www.blogger.com/atom/ns#" term="C++"/><category scheme="http://www.blogger.com/atom/ns#" term="cmath library"/><category scheme="http://www.blogger.com/atom/ns#" term="log functions"/><title type='text'>The Base 10 Log Function in C &amp; C++</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
I am making may way through all the different functions in
the various standard header files that form part of C and C++. I’m still
working on the contents of the &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;lt;math.h&amp;gt;&lt;/span&gt;
or &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;lt;cmath&amp;gt;&lt;/span&gt; header files.
Today is about the base 10 logarithmic function. &lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
Say, ten, raised to the power of x, is N then the base 10
log of N is x. Example, 10 squared is 100. The base 10 log of 100 is 2 since 10
to the 2 is 100.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&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/AVvXsEgpoc7T-X-sFlQJEp3V9v8V_Wrr1QQW59cBQFMccOE6xg8IZzsaxV_H0_8CHE7iWtEH386PBKgiReZhT9uIVFjYCxZQ2xS673-3iDfrZJzJL45qqjRiLHAhXN9Dcv5f8na7HtmkzzXGiwc/s1600/Base++10+Log.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;196&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpoc7T-X-sFlQJEp3V9v8V_Wrr1QQW59cBQFMccOE6xg8IZzsaxV_H0_8CHE7iWtEH386PBKgiReZhT9uIVFjYCxZQ2xS673-3iDfrZJzJL45qqjRiLHAhXN9Dcv5f8na7HtmkzzXGiwc/s400/Base++10+Log.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
The &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;exp()&lt;/span&gt; and &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;log()&lt;/span&gt; functions are related
since the return value of one can be passed to the other in a circle. There is
no sister function for &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;log10()&lt;/span&gt;, you have to use the power function with base
10.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
Here is a snippet from the C standard (C11 N1570).&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&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/AVvXsEjrvmSagFt0dqMk6smEQZ8-nMTmxRc6_MkX2zgs6wCreXbXb4WmcZi1FxdGT4Vo5yZPTns1tE3fRcrdfhvlrRxorhsTwv5FeDfym4i24gdiTUOGqb5g97br5lwd0rGJJuJCSZZ33ZV56Po/s1600/ISO+Standard+-+log10+Function.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;171&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjrvmSagFt0dqMk6smEQZ8-nMTmxRc6_MkX2zgs6wCreXbXb4WmcZi1FxdGT4Vo5yZPTns1tE3fRcrdfhvlrRxorhsTwv5FeDfym4i24gdiTUOGqb5g97br5lwd0rGJJuJCSZZ33ZV56Po/s400/ISO+Standard+-+log10+Function.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
What does a domain error mean? First, it only occurs in
relation to the functions in the math library. Second, it means you passed an
argument to the function which is outside of the range of arguments allowed. The
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;log10&lt;/span&gt; function only allows
numbers greater than zero.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
From subclause 7.12.1 of the C11 standard:&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;background: #E6E6E6; border: solid windowtext 1.0pt; margin-left: 28.35pt; margin-right: 42.55pt; mso-border-alt: solid windowtext .5pt; mso-element: para-border-div; padding: 1.0pt 4.0pt 1.0pt 4.0pt;&quot;&gt;
&lt;div class=&quot;QuoteBox&quot; style=&quot;background: #E6E6E6; margin-bottom: 12.0pt; margin-left: 0in; margin-right: 0in; margin-top: 12.0pt;&quot;&gt;
For all functions, a &lt;i&gt;domain error &lt;/i&gt;occurs
if an input argument is outside the domain over which the mathematical function
is defined. The description of each function lists any required domain errors;
an implementation may define additional domain errors, provided that such
errors are consistent with the mathematical definition of the function.&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
The
return value for a &lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;domain error&lt;/b&gt; is
dependent on the compiler. In Visual C++ 2010, the return value is &lt;span class=&quot;eNoIndentChar&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;-1.#IND000000000000&lt;/span&gt;. I suspect the IND stands for
indeterminate. Try a google search on that return value.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span class=&quot;eNoIndentChar&quot;&gt;A &lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;pole error&lt;/b&gt;
indicates the return value approaches zero or positive or negative infinity
under the limit functions in calculus. The implement of a pole error is
compiler dependent and in Visual&lt;/span&gt; C++ 2010, the return value is &lt;span class=&quot;eNoIndentChar&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;-1.#INF000000000000&lt;/span&gt; or negative infinity.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
Passing a non-positive argument to the function does not
result in a compile or run-time error. It’s up to the programmer to ensure
proper argument values are passed to the function.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;Test Code.&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
I tested the functions in Visual C++ 2010 as an console
application.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
Interestingly, I discovered something about the &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;printf&lt;/span&gt;
function. It prints out zeros when there is a mismatch between a format
specifier and the argument. I used “%d” with a float variable and “%f” with
other floats. In all cases zero was displayed even when there variables weren’t
zero. More on that in another blog, but once I matched them, it worked
properly.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: green; font-family: Consolas;&quot;&gt;// The
standard library includes the system function.&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt; &lt;span style=&quot;color: #a31515;&quot;&gt;&amp;lt;cstdlib&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: green; font-family: Consolas;&quot;&gt;// C++
standard I/O library.&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt; &lt;span style=&quot;color: #a31515;&quot;&gt;&amp;lt;cstdio&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: green; font-family: Consolas;&quot;&gt;// C++
math library.&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt; &lt;span style=&quot;color: #a31515;&quot;&gt;&amp;lt;cmath&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt; main()&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Header.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;Logarithmic
Base 10 Function\n\n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;\tn\t&amp;nbsp;&amp;nbsp; log10(n)\t10^log10((n)) \n\n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Counter.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; i;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Argument.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;double&lt;/span&gt; n;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;for&lt;/span&gt; (i = 0;
i &amp;lt; 8; ++i)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; n = pow(10.0, i);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;%9.0f\t%10.4f\t%10.0f\n&quot;&lt;/span&gt;,
n, log10(n), pow(10.0,log10(n)));&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;\n\n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Negative argument.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;Negative
argument: %f &quot;&lt;/span&gt;, log10(-1.0));&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;\n\n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Zero value
argument.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;Zero
value argument: %f &quot;&lt;/span&gt;, log10(0.0));&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;\n\n&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Keep console
window open.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; system(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;pause&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;// Return some
value.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt; 0;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;} &lt;span style=&quot;color: green;&quot;&gt;// end main&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;Output.&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&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/AVvXsEhr94hKWCe60vOcCOTPwiLA8IkvIDwDHnfjMkhIs_hJkngNnqyylkRKu93Uil3VMxSme-4kJud1kkEswK3rJ7y0LD7G0PEcJMu4wTSU9kDskCMg6zbdT7B9pKvUZYgurQsxSY_m2RtLqP0/s1600/2012.03.06+-+LessonsInCoding+-+The+Base+10+Log+Function+in+C+%2526+C%252B%252B.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;206&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhr94hKWCe60vOcCOTPwiLA8IkvIDwDHnfjMkhIs_hJkngNnqyylkRKu93Uil3VMxSme-4kJud1kkEswK3rJ7y0LD7G0PEcJMu4wTSU9kDskCMg6zbdT7B9pKvUZYgurQsxSY_m2RtLqP0/s400/2012.03.06+-+LessonsInCoding+-+The+Base+10+Log+Function+in+C+%2526+C%252B%252B.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lessonsincoding.blogspot.com/feeds/2787752970977020381/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://lessonsincoding.blogspot.com/2012/03/base-10-log-function-in-c-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5207350420173720706/posts/default/2787752970977020381'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5207350420173720706/posts/default/2787752970977020381'/><link rel='alternate' type='text/html' href='http://lessonsincoding.blogspot.com/2012/03/base-10-log-function-in-c-c.html' title='The Base 10 Log Function in C &amp; C++'/><author><name>James Piper</name><uri>http://www.blogger.com/profile/12387224587116087657</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGQ4ESUam_EJLtqp-f18iDIo2m7iCu_98TmJKP8if7vNZ76wasSEUxtnQLbxLqMcA2n9ozNH5PtbOy--l1i2r1znz7zBuCRwmXJOZCl1W_2WuKBPIJENOsjUnf27ltTw/s220/james_piper+sqr+image.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpoc7T-X-sFlQJEp3V9v8V_Wrr1QQW59cBQFMccOE6xg8IZzsaxV_H0_8CHE7iWtEH386PBKgiReZhT9uIVFjYCxZQ2xS673-3iDfrZJzJL45qqjRiLHAhXN9Dcv5f8na7HtmkzzXGiwc/s72-c/Base++10+Log.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5207350420173720706.post-3105292128047288673</id><published>2012-03-06T16:57:00.000-05:00</published><updated>2012-03-25T14:43:03.071-04:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C"/><category scheme="http://www.blogger.com/atom/ns#" term="C++"/><title type='text'>Backslash Line Splicing in C &amp; C++</title><content type='html'>&lt;br /&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
I was playing around with some code in Visual C++ 2010 and
at one point I typed a backslash key. The result surprised me.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
Here’s an example of what I had:&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: green; font-family: Consolas;&quot;&gt;// Some comment about main function.&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt; main()&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
Here’s what happened when I added a backslash at the end of
the comment.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: green; font-family: Consolas;&quot;&gt;// Some comment about main function.\&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: green; font-family: Consolas;&quot;&gt;int main()&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
The &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;int main&lt;/span&gt; function turned green meaning
it was commented. The program wouldn’t compile. I got this error message: &lt;span style=&quot;font-family: Consolas; font-size: 9pt;&quot;&gt;error
C2447: &#39;{&#39; : missing function header&lt;/span&gt;&lt;/div&gt;
&amp;nbsp;

&lt;br /&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
What was going on?&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
If I removed the backslash, everything was fine. If I added
other characters after the backslash, everything was fine. It had nothing to do
with the backslash used in escape sequences and the reference material on
adding comments to C or C++ code didn’t discuss a backslash, it was the slash
character.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
A quick search or two revealed the answer in something
called line splicing.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
In Appendix A.12 of &lt;span style=&quot;font-family: Garamond; font-size: 12pt;&quot;&gt;&lt;a href=&quot;http://lessonsincoding.blogspot.com/p/c-programming-language-k.html&quot;&gt;K&amp;amp;R&lt;/a&gt;&lt;/span&gt; they write: &lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;background: #E6E6E6; border: solid windowtext 1.0pt; margin-left: 28.35pt; margin-right: 42.55pt; mso-border-alt: solid windowtext .5pt; mso-element: para-border-div; padding: 1.0pt 4.0pt 1.0pt 4.0pt;&quot;&gt;
&lt;div class=&quot;QuoteBox&quot; style=&quot;background: #E6E6E6; margin-bottom: 12.0pt; margin-left: 0in; margin-right: 0in; margin-top: 12.0pt;&quot;&gt;
Each occurrence of a backslash character &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;\ &lt;/span&gt;followed by a
newline is deleted, this splices lines.&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
When you compile your source files, the compiler executes a
pre-processing stage where comments are removed and lines with the backslash
and newline characters are deleted.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
Another lesson learnt in the world of coding.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lessonsincoding.blogspot.com/feeds/3105292128047288673/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://lessonsincoding.blogspot.com/2012/03/backslash-line-splicing-in-c-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5207350420173720706/posts/default/3105292128047288673'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5207350420173720706/posts/default/3105292128047288673'/><link rel='alternate' type='text/html' href='http://lessonsincoding.blogspot.com/2012/03/backslash-line-splicing-in-c-c.html' title='Backslash Line Splicing in C &amp; C++'/><author><name>James Piper</name><uri>http://www.blogger.com/profile/12387224587116087657</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGQ4ESUam_EJLtqp-f18iDIo2m7iCu_98TmJKP8if7vNZ76wasSEUxtnQLbxLqMcA2n9ozNH5PtbOy--l1i2r1znz7zBuCRwmXJOZCl1W_2WuKBPIJENOsjUnf27ltTw/s220/james_piper+sqr+image.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5207350420173720706.post-2777508173130648820</id><published>2012-03-05T17:58:00.000-05:00</published><updated>2012-03-25T14:42:27.396-04:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C"/><category scheme="http://www.blogger.com/atom/ns#" term="C++"/><category scheme="http://www.blogger.com/atom/ns#" term="cmath library"/><category scheme="http://www.blogger.com/atom/ns#" term="trig functions"/><title type='text'>Summary of Log Functions in C &amp; C++</title><content type='html'>&lt;br /&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
The following is a summary of logs functions in C and C++. &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;lt;math.h&amp;gt;&lt;/span&gt; library in C, &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;lt;cmath&amp;gt;&lt;/span&gt; in C++.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
C++ overloads the functions for different data types.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;a href=&quot;http://lessonsincoding.blogspot.com/2012/03/natural-logarithmic-functions-in-c-c.html&quot;&gt;e
to the nth power&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
In C&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;double exp(double)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;float expf(float)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;long double expl(long double)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
In C++&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;double | float | long exp(double |
float | long)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;a href=&quot;http://lessonsincoding.blogspot.com/2012/03/natural-logarithmic-functions-in-c-c.html&quot;&gt;Natural
Logarithm&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
In C&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;double log(double)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;float logf(float)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;long double logl(long double)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
In C++&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;double | float | long log(double |
float | long)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;a href=&quot;http://lessonsincoding.blogspot.com/2012/03/base-10-log-function-in-c-c.html&quot;&gt;Base
10 Log&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
In C&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;double log10(double)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;float log10f(float)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;long double log10l(long double)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
In C++&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;double | float | long log10(double |
float | long)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;C11 / C+11 Standards&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
The most recent updates to the language standards introduce
several new log functions. None are implemented in Visual C++ 2010.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
Here’s the list.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
exp2&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; raise 2 to the nth power&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
log 2&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; companion
to exp2&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
expm1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; is
exp(n) – 1 with more precision&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
logm1&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; log(n+1)
with more precision&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lessonsincoding.blogspot.com/feeds/2777508173130648820/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://lessonsincoding.blogspot.com/2012/03/summary-of-log-functions-in-c-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5207350420173720706/posts/default/2777508173130648820'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5207350420173720706/posts/default/2777508173130648820'/><link rel='alternate' type='text/html' href='http://lessonsincoding.blogspot.com/2012/03/summary-of-log-functions-in-c-c.html' title='Summary of Log Functions in C &amp; C++'/><author><name>James Piper</name><uri>http://www.blogger.com/profile/12387224587116087657</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGQ4ESUam_EJLtqp-f18iDIo2m7iCu_98TmJKP8if7vNZ76wasSEUxtnQLbxLqMcA2n9ozNH5PtbOy--l1i2r1znz7zBuCRwmXJOZCl1W_2WuKBPIJENOsjUnf27ltTw/s220/james_piper+sqr+image.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5207350420173720706.post-531918273833890571</id><published>2012-03-05T17:20:00.001-05:00</published><updated>2012-03-25T14:42:13.058-04:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C"/><category scheme="http://www.blogger.com/atom/ns#" term="C++"/><category scheme="http://www.blogger.com/atom/ns#" term="cmath library"/><category scheme="http://www.blogger.com/atom/ns#" term="trig functions"/><title type='text'>Summary of Trig Functions in C &amp; C++</title><content type='html'>&lt;div class=&quot;eNoIndent&quot;&gt;
The following is a summary of trig functions in C and C++. &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;lt;math.h&amp;gt;&lt;/span&gt; library in C, &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;lt;cmath&amp;gt;&lt;/span&gt; in C++.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
C++ overloads the functions for different data types.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;a href=&quot;http://lessonsincoding.blogspot.com/2012/02/sine-arcsine-functions-in-c-c.html&quot;&gt;Sine
&amp;amp; Arcsine Functions&lt;/a&gt;:&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
In C&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;double sin(double)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;float sinf(float)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;long double sinl(long double)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;double asin(double)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;float asinf(float)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;long double asinl(long double)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
In C++&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;double | float | long sin(double |
float | long)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;double | float | long asin(double |
float | long)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;a href=&quot;http://lessonsincoding.blogspot.com/2012/02/cosine-arccosine-functions-in-c-c.html&quot;&gt;Cosine
&amp;amp; Arccosine Functions&lt;/a&gt;:&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
In C&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;double cos(double)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;float cosf(float)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;long double cosl(long double)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;double acos(double)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;float acosf(float)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;long double acos(long double)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
In C++&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;double | float | long cos(double |
float | long)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;double | float | long acos(double |
float | long)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;a href=&quot;http://lessonsincoding.blogspot.com/2012/02/tangent-arctangent-functions-in-c-c.html&quot;&gt;Tangent
&amp;amp; Arctangent Functions&lt;/a&gt;:&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
In C&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;double tan(double)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;float tanf(float)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;long double tanl(long double)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;double atan(double)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;float atanf(float)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;long double atanf(long double)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
In C++&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;double | float | long tan(double |
float | long)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;double | float | long atan(double |
float | long)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;Hyperbolic Trig
Functions:&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
In C&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;double sinh(double)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;float sinhf(float)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;long double sinhl(long double)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;double cosh(double)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;float coshf(float)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;long double coshl(long double)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;double tanh(double)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;float tanhf(float)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;long double tanhl(long double)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;double asinh(double)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;float asinhf(float)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;long double asinhl(long double)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;double acosh(double)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;float acoshf(float)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;long double acosh(long double)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;double atanh(double)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;float atanhf(float)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;long double atanhf(long double)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
In C++&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt;double
| float | long &lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;sinh(double | float | long)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;double | float | long cosh(double |
float | long)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot; style=&quot;margin-left: .5in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;double | float | long tanh(double | float
| long)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
The C++11 standard brings in &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;asinh&lt;/span&gt;, &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;acosh&lt;/span&gt;, &amp;amp; &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;atanh&lt;/span&gt;.
These functions aren’t implemented in Visual C++ 2010.&lt;/div&gt;
&lt;div class=&quot;eNoIndent&quot;&gt;
&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lessonsincoding.blogspot.com/feeds/531918273833890571/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://lessonsincoding.blogspot.com/2012/03/summary-of-trig-functions-in-c-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5207350420173720706/posts/default/531918273833890571'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5207350420173720706/posts/default/531918273833890571'/><link rel='alternate' type='text/html' href='http://lessonsincoding.blogspot.com/2012/03/summary-of-trig-functions-in-c-c.html' title='Summary of Trig Functions in C &amp; C++'/><author><name>James Piper</name><uri>http://www.blogger.com/profile/12387224587116087657</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGQ4ESUam_EJLtqp-f18iDIo2m7iCu_98TmJKP8if7vNZ76wasSEUxtnQLbxLqMcA2n9ozNH5PtbOy--l1i2r1znz7zBuCRwmXJOZCl1W_2WuKBPIJENOsjUnf27ltTw/s220/james_piper+sqr+image.jpg'/></author><thr:total>0</thr:total></entry></feed>