<?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-650183537613822215</id><updated>2024-10-24T07:32:48.605-07:00</updated><category term="C TUTORIAL"/><category term="POINTERS"/><category term="THE C PREPROCESSOR"/><category term="ACCESSING EXPANDED MEMORY"/><category term="ACCESSING EXTENDED MEMORY"/><category term="ADVANCED GRAPHICS ON THE PC"/><category term="ANYFILE.C"/><category term="ASSIGNMENT AND LOGICAL COMPARES"/><category term="ATEXIT"/><category term="Advanced C programing"/><category term="BACKWARD.C"/><category term="BETTERIN.C"/><category term="BIGARRAY.C"/><category term="BIGDYNL.C"/><category term="BITFIELD.C"/><category term="BITOPS.C"/><category term="BREAKCON.C"/><category term="Basic Programs In C"/><category term="C Aptitude"/><category term="C LANGUAGE"/><category term="C Programming"/><category term="C in 13 hours"/><category term="CAST"/><category term="CHARACTER AND BIT MANIPULATION"/><category term="CHARCLAS.C"/><category term="CHAROUT.C"/><category term="CHRSTRG.C"/><category term="COMBINE.C"/><category term="COMMENTS.C"/><category term="COMPARES.C"/><category term="CRYPTIC.C"/><category term="DANGEROUS PITFALLS"/><category term="DATA TYPES"/><category term="DEBUGEX.C"/><category term="DEBUGGING"/><category term="DEFINE.C"/><category term="DIRECT VIDEO ACCESS WITH THE PC"/><category term="DIRECTORY SEARCHING WITH PC AND DOS"/><category term="DOWHILE.C"/><category term="DUMBCONV.C"/><category term="DYNAMIC ALLOCATION"/><category term="DYNAMIC MEMORY ALLOCATION"/><category term="DYNLINK.C"/><category term="DYNLIST.C"/><category term="ENUM.C"/><category term="ERROR HANDLING"/><category term="FILE I/O"/><category term="FILE INPUT/OUTPUT"/><category term="FIRSTEX.C"/><category term="FLOAT ERRORS"/><category term="FLOATSQ.C"/><category term="FLOATSQ2.C"/><category term="FORLOOP.C"/><category term="FORMOUT.C"/><category term="FUNCPNT.C"/><category term="FUNCTIONS"/><category term="FUNCTIONS VARIABLES AND PROTOTYPES"/><category term="GOODFORM.C"/><category term="GOTOEX.C"/><category term="HEADER FILES"/><category term="IFDEF.C"/><category term="IFELSE.C"/><category term="IFNDEF.C"/><category term="INCREASING SPEED"/><category term="INMEM.C"/><category term="INPUT AND OUTPUT"/><category term="INTARRAY.C"/><category term="INTASIGN.C"/><category term="INTERFACING C WITH CLIPPER"/><category term="INTIN.C"/><category term="INTRODUCTION"/><category term="International Certificate In  C Language"/><category term="LOTTYPES.C"/><category term="Link Lists"/><category term="MACRO.C"/><category term="MORTYPES.C"/><category term="MULTIARY.C"/><category term="NESTED.C"/><category term="ONEINT.C"/><category term="OPERATORS"/><category term="PASSBACK.C"/><category term="PC GRAPHICS"/><category term="POINTER.C"/><category term="POINTER2.C"/><category term="POINTERS TO FUNCTIONS"/><category term="PRINTDAT.C"/><category term="PROGRAM CONTROL"/><category term="PROGRAM CONTROL STATEMENTS"/><category term="Programs In ASSIGNMENT AND LOGICAL COMPARES of  C"/><category term="Programs In C Preprocessor"/><category term="Programs In Controls Of C"/><category term="Programs In DYNAMIC ALLOCATION Of C"/><category term="Programs In FUNCTIONS  VARIABLES AND PROTOTYPES of C"/><category term="Programs In File I/O of C"/><category term="Programs In I/O Of C"/><category term="Programs In Pointer  Of C"/><category term="Programs In STRINGS AND ARRAYS Of C"/><category term="Programs In STRUCTURES AND UNIONS Of C"/><category term="Questions : Declarations and Initializations"/><category term="READCHAR.C"/><category term="READGOOD.C"/><category term="READLINE.C"/><category term="READTEXT.C"/><category term="RECURSON.C"/><category term="SCOPE.C"/><category term="SHIFTER.C"/><category term="SIGNAL"/><category term="SIMPLEIO.C"/><category term="SINGLEIO.C"/><category term="SIZEOF"/><category term="SORTING AND SEARCHING"/><category term="SPECIAL.C"/><category term="SQUARES.C"/><category term="STANDARD INPUT/OUTPUT"/><category term="STRINGIN.C"/><category term="STRINGS"/><category term="STRINGS AND ARRAYS"/><category term="STRINGS.C"/><category term="STRUCT1.C"/><category term="STRUCT2.C"/><category term="STRUCT3.C"/><category term="STRUCTURES"/><category term="STRUCTURES AND UNIONS"/><category term="STYLE1.C"/><category term="STYLE2.C"/><category term="STYLE3.C"/><category term="STYLE3.H"/><category term="SUMSQRES.C"/><category term="SWITCH.C"/><category term="TEMPCONV.C"/><category term="TEXT HANDLING"/><category term="THE IMPORTANCE OF PROTOTYPING"/><category term="TIME"/><category term="TRIGONOMETRY FUNCTIONS"/><category term="TRIVIAL.C"/><category term="TWOWAY.C"/><category term="UGLYFORM.C"/><category term="UNION1.C"/><category term="UNION2.C"/><category term="UPLOW.C"/><category term="USING LINK"/><category term="VARIABLE ARGUMENT LISTS"/><category term="WHILE.C"/><category term="WRTMORE.C"/><category term="WRTSOME.C"/><title type='text'>C Language Tutorial And Complete Reference</title><subtitle type='html'>This C Tutorial aims at getting a reader new to C started.You Can Learn C in 13 Hours By this 13 Chapters And also we are giving Complete Reference Of C language To You</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://c-completereference.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/650183537613822215/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://c-completereference.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/650183537613822215/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>146</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-650183537613822215.post-7894902632317019556</id><published>2012-12-18T09:25:00.000-08:00</published><updated>2018-10-07T06:30:27.148-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Advanced C programing"/><category scheme="http://www.blogger.com/atom/ns#" term="C in 13 hours"/><category scheme="http://www.blogger.com/atom/ns#" term="C LANGUAGE"/><category scheme="http://www.blogger.com/atom/ns#" term="C TUTORIAL"/><title type='text'>C TUTORIAL</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;center&gt;&lt;b&gt;C&amp;nbsp;LANGUAGE&amp;nbsp;&lt;/b&gt;&lt;/center&gt;&lt;center&gt;&lt;b&gt;TUTORIAL &lt;/b&gt;&lt;/center&gt;&lt;br /&gt;
&lt;div style=&quot;margin: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;margin: 0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;margin: 0px;&quot;&gt;This tutorial teaches the entire C programming language. It is composed&amp;nbsp;of 13 chapters which should be studied in order since topics are introduced&amp;nbsp;in a logical order &lt;/div&gt;&lt;div style=&quot;margin: 0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;margin: 0px;&quot;&gt;It is to the students benefit to download the source code for the example&amp;nbsp;programs, then compile and execute each program as it is studied. The diligent&amp;nbsp;student will modify the example program in some way, then recompile and&amp;nbsp;execute it to see if he understands the material studied for that program.&lt;/div&gt;&lt;div style=&quot;margin: 0px;&quot;&gt;This will provide the student with valuable experience using his compiler.&lt;/div&gt;&lt;br /&gt;
&lt;div style=&quot;margin: 0px; text-align: center;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red; font-size: large;&quot;&gt;&lt;b&gt;If you New to&amp;nbsp; C Language&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;dl&gt;&lt;ul&gt;&lt;dt&gt;&amp;nbsp;&lt;/dt&gt;
&lt;dt&gt;&amp;nbsp;Don&#39;t worry about C language You Can easily &lt;b&gt;Learn C within 13 hour&lt;/b&gt; with Help of Our Overview of C language which Contain 13 Chapter.with help of those 13 Chapter You Can Learn C&lt;/dt&gt;
&lt;dt&gt;&lt;br /&gt;
&lt;/dt&gt;
&lt;dt style=&quot;text-align: center;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&lt;a href=&quot;http://c-completereference.blogspot.com/p/c-in-13hrs.html&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;b&gt;Click Here To learn C in 13 Hours&lt;/b&gt;&lt;/span&gt;&lt;/a&gt;&amp;nbsp;&lt;/span&gt;&amp;nbsp;&amp;nbsp;&lt;/dt&gt;
&lt;dt style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;
&lt;/dt&gt;
&lt;dt style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;
&lt;/dt&gt;
&lt;dt style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;
&lt;/dt&gt;
&lt;dt style=&quot;text-align: center;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red; font-size: large;&quot;&gt;&lt;b&gt;If you Want Prepare For International Certificate In&amp;nbsp; C Language&lt;/b&gt;&lt;/span&gt;&lt;/dt&gt;
&lt;dt style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/dt&gt;
&lt;dt style=&quot;text-align: left;&quot;&gt;Making a International Certificate for C language was so easy you have to prepare all topic in C language and also you have to workout more example program&lt;/dt&gt;
&lt;dt style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;
&lt;/dt&gt;
&lt;dt style=&quot;color: #93c47d; text-align: center;&quot;&gt;&lt;a href=&quot;http://c-completereference.blogspot.com/p/complete-reference.html&quot;&gt;&lt;b&gt;Click Here To Learn Complete Reference &lt;/b&gt;&lt;/a&gt;&lt;/dt&gt;
&lt;dt style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;
&lt;/dt&gt;
&lt;dt&gt;&lt;br /&gt;
&lt;/dt&gt;
&lt;dt&gt;&lt;br /&gt;
&lt;/dt&gt;
&lt;dt&gt;Good Luck for Your Preparation&lt;/dt&gt;
&lt;dt&gt;&lt;br /&gt;
&lt;/dt&gt;
&lt;/ul&gt;&lt;/dl&gt;&lt;/div&gt;

&lt;iframe width=&quot;360&quot; height=&quot;202&quot; src=&quot;https://www.youtube.com/embed/q5brtcDRdwI?rel=0&amp;amp;autoplay=1&amp;mute=1&quot; frameborder=&quot;0&quot; allowfullscreen&gt;&lt;/iframe&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;SCRIPT LANGUAGE=&quot;JavaScript1.1&quot; SRC=&quot;http://bdv.bidvertiser.com/BidVertiser.dbm?pid=356752&amp;bid=1629957&quot; type=&quot;text/javascript&quot;&gt;&lt;/SCRIPT&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/650183537613822215/posts/default/7894902632317019556'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/650183537613822215/posts/default/7894902632317019556'/><link rel='alternate' type='text/html' href='http://c-completereference.blogspot.com/2010/12/topics-under-c-language.html' title='C TUTORIAL'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://img.youtube.com/vi/q5brtcDRdwI/default.jpg" height="72" width="72"/></entry><entry><id>tag:blogger.com,1999:blog-650183537613822215.post-7643839526007754996</id><published>2011-03-17T11:41:00.001-07:00</published><updated>2013-08-16T05:49:50.582-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C Aptitude"/><category scheme="http://www.blogger.com/atom/ns#" term="C Programming"/><category scheme="http://www.blogger.com/atom/ns#" term="Questions : Declarations and Initializations"/><title type='text'>Which of the following statements should be used to obtain a remainder after dividing 3.14 by 2.1 ?</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;1.    Which of the following statements should be used to obtain a remainder after dividing 3.14 by 2.1 ?&lt;br&gt;
&lt;br&gt;
A.  rem = 3.14 % 2.1;&lt;br&gt;
B.  rem = modf(3.14, 2.1);&lt;br&gt;
C.  rem = fmod(3.14, 2.1);&lt;br&gt;
D.  Remainder cannot be obtain in floating point division.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;/div&gt;&lt;a href=&quot;http://c-completereference.blogspot.com/2011/03/which-of-following-statements-should-be.html#more&quot;&gt;Read more »&lt;/a&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;SCRIPT LANGUAGE=&quot;JavaScript1.1&quot; SRC=&quot;http://bdv.bidvertiser.com/BidVertiser.dbm?pid=356752&amp;bid=1629957&quot; type=&quot;text/javascript&quot;&gt;&lt;/SCRIPT&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/650183537613822215/posts/default/7643839526007754996'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/650183537613822215/posts/default/7643839526007754996'/><link rel='alternate' type='text/html' href='http://c-completereference.blogspot.com/2011/03/which-of-following-statements-should-be.html' title='Which of the following statements should be used to obtain a remainder after dividing 3.14 by 2.1 ?'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-650183537613822215.post-2140238500764192236</id><published>2011-03-17T10:40:00.000-07:00</published><updated>2011-03-17T10:41:48.697-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C TUTORIAL"/><category scheme="http://www.blogger.com/atom/ns#" term="International Certificate In  C Language"/><title type='text'>If you Want Prepare For International Certificate In  C Language</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;ul&gt;&lt;dt style=&quot;text-align: left;&quot;&gt;Making a International Certificate for C  language was so easy you have to prepare all topic in C language and  also you have to workout more example program&lt;/dt&gt;
&lt;dt style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;
&lt;/dt&gt;
&lt;dt style=&quot;color: #93c47d; text-align: center;&quot;&gt;&lt;a href=&quot;http://c-completereference.blogspot.com/p/complete-reference.html&quot;&gt;&lt;b&gt;Click Here To Learn Complete Reference &lt;/b&gt;&lt;/a&gt;&lt;/dt&gt;
&lt;dt style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;
&lt;/dt&gt;
&lt;dt style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;
&lt;/dt&gt;
&lt;/ul&gt;&lt;h2&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;This will Give you Complete Reference of C language More Topic in this other than that 13hrs Chapter&lt;/span&gt;&lt;/h2&gt;&lt;h2&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;Study These Topic and Challenge Your Friends&lt;/span&gt;&lt;/h2&gt;&lt;h2&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;
This will Help You to Write Exam in C even For International Certification&amp;nbsp; &lt;/span&gt;&lt;/h2&gt;&lt;h2&gt;&amp;nbsp;&lt;/h2&gt;&lt;h2&gt;Topic Under C For  International Certificate&lt;/h2&gt;&lt;div class=&quot;widget-content&quot;&gt;&lt;ul&gt;&lt;li&gt; &lt;a dir=&quot;ltr&quot; href=&quot;http://c-completereference.blogspot.com/search/label/POINTERS&quot;&gt;POINTERS&lt;/a&gt; &lt;/li&gt;
&lt;li&gt; &lt;a dir=&quot;ltr&quot; href=&quot;http://c-completereference.blogspot.com/2010/12/c-preprocessor.html&quot;&gt;THE C PREPROCESSOR&lt;/a&gt; &lt;/li&gt;
&lt;li&gt; &lt;a dir=&quot;ltr&quot; href=&quot;http://c-completereference.blogspot.com/2010/12/accessing-expanded-memory.html&quot;&gt;ACCESSING EXPANDED MEMORY&lt;/a&gt; &lt;/li&gt;
&lt;li&gt; &lt;a dir=&quot;ltr&quot; href=&quot;http://c-completereference.blogspot.com/2010/12/accessing-extended-memory.html&quot;&gt;ACCESSING EXTENDED MEMORY&lt;/a&gt; &lt;/li&gt;
&lt;li&gt; &lt;a dir=&quot;ltr&quot; href=&quot;http://c-completereference.blogspot.com/2010/12/advanced-graphics-on-ibm-pc.html&quot;&gt;ADVANCED GRAPHICS ON THE PC&lt;/a&gt; &lt;/li&gt;
&lt;li&gt; &lt;a dir=&quot;ltr&quot; href=&quot;http://c-completereference.blogspot.com/2010/12/chapter-4.html&quot;&gt;ASSIGNMENT AND LOGICAL COMPARES&lt;/a&gt; &lt;/li&gt;
&lt;li&gt; &lt;a dir=&quot;ltr&quot; href=&quot;http://c-completereference.blogspot.com/2010/12/atexit_17.html&quot;&gt;ATEXIT&lt;/a&gt; &lt;/li&gt;
&lt;li&gt; &lt;a dir=&quot;ltr&quot; href=&quot;http://c-completereference.blogspot.com/2010/12/cast.html&quot;&gt;CAST&lt;/a&gt; &lt;/li&gt;
&lt;li&gt; &lt;a dir=&quot;ltr&quot; href=&quot;http://c-completereference.blogspot.com/2010/12/chapter-13.html&quot;&gt;CHARACTER AND BIT MANIPULATION&lt;/a&gt; &lt;/li&gt;
&lt;li&gt; &lt;a dir=&quot;ltr&quot; href=&quot;http://c-completereference.blogspot.com/2010/12/dangerous-pitfalls.html&quot;&gt;DANGEROUS PITFALLS&lt;/a&gt; &lt;/li&gt;
&lt;li&gt; &lt;a dir=&quot;ltr&quot; href=&quot;http://c-completereference.blogspot.com/2010/12/data-types.html&quot;&gt;DATA TYPES&lt;/a&gt; &lt;/li&gt;
&lt;li&gt; &lt;a dir=&quot;ltr&quot; href=&quot;http://c-completereference.blogspot.com/2010/12/debugging.html&quot;&gt;DEBUGGING&lt;/a&gt; &lt;/li&gt;
&lt;li&gt; &lt;a dir=&quot;ltr&quot; href=&quot;http://c-completereference.blogspot.com/2010/12/direct-video-access-with-pc.html&quot;&gt;DIRECT VIDEO ACCESS WITH THE PC&lt;/a&gt; &lt;/li&gt;
&lt;li&gt; &lt;a dir=&quot;ltr&quot; href=&quot;http://c-completereference.blogspot.com/2010/12/directory-searching-with-pc-and-dos.html&quot;&gt;DIRECTORY SEARCHING WITH PC AND DOS&lt;/a&gt; &lt;/li&gt;
&lt;li&gt; &lt;a dir=&quot;ltr&quot; href=&quot;http://c-completereference.blogspot.com/2010/12/chapter-12.html&quot;&gt;DYNAMIC ALLOCATION Overview&lt;/a&gt; &lt;/li&gt;
&lt;li&gt; &lt;a dir=&quot;ltr&quot; href=&quot;http://c-completereference.blogspot.com/2010/12/dynamic-memory-allocation.html&quot;&gt;DYNAMIC MEMORY ALLOCATION Detail&lt;/a&gt; &lt;/li&gt;
&lt;li&gt; &lt;a dir=&quot;ltr&quot; href=&quot;http://c-completereference.blogspot.com/2010/12/error-handling.html&quot;&gt;ERROR HANDLING&lt;/a&gt; &lt;/li&gt;
&lt;li&gt; &lt;a dir=&quot;ltr&quot; href=&quot;http://c-completereference.blogspot.com/2010/12/file-io.html&quot;&gt;FILE I/O In Detail&lt;/a&gt; &lt;/li&gt;
&lt;li&gt; &lt;a dir=&quot;ltr&quot; href=&quot;http://c-completereference.blogspot.com/2010/12/chapter-10.html&quot;&gt;FILE INPUT/OUTPUT Overview&lt;/a&gt; &lt;/li&gt;
&lt;li&gt; &lt;a dir=&quot;ltr&quot; href=&quot;http://c-completereference.blogspot.com/2010/12/float-errors.html&quot;&gt;FLOAT ERRORS&lt;/a&gt; &lt;/li&gt;
&lt;li&gt; &lt;a dir=&quot;ltr&quot; href=&quot;http://c-completereference.blogspot.com/2010/12/functions.html&quot;&gt;FUNCTIONS&lt;/a&gt; &lt;/li&gt;
&lt;li&gt; &lt;a dir=&quot;ltr&quot; href=&quot;http://c-completereference.blogspot.com/2010/12/chapter-5.html&quot;&gt;FUNCTIONS VARIABLES AND PROTOTYPES&lt;/a&gt; &lt;/li&gt;
&lt;li&gt; &lt;a dir=&quot;ltr&quot; href=&quot;http://c-completereference.blogspot.com/2010/12/header-files.html&quot;&gt;HEADER FILES&lt;/a&gt; &lt;/li&gt;
&lt;li&gt; &lt;a dir=&quot;ltr&quot; href=&quot;http://c-completereference.blogspot.com/2010/12/increasing-speed.html&quot;&gt;INCREASING SPEED&lt;/a&gt; &lt;/li&gt;
&lt;li&gt; &lt;a dir=&quot;ltr&quot; href=&quot;http://c-completereference.blogspot.com/2010/12/input-and-output.html&quot;&gt;INPUT AND OUTPUT&lt;/a&gt; &lt;/li&gt;
&lt;li&gt; &lt;a dir=&quot;ltr&quot; href=&quot;http://c-completereference.blogspot.com/2010/12/interfacing-c-with-clipper.html&quot;&gt;INTERFACING C WITH CLIPPER&lt;/a&gt; &lt;/li&gt;
&lt;li&gt; &lt;a dir=&quot;ltr&quot; href=&quot;http://c-completereference.blogspot.com/2010/12/introduction_17.html&quot;&gt;INTRODUCTION Detail&lt;/a&gt; &lt;/li&gt;
&lt;li&gt; &lt;a dir=&quot;ltr&quot; href=&quot;http://c-completereference.blogspot.com/2010/12/link-lists.html&quot;&gt;LINK LISTS&lt;/a&gt; &lt;/li&gt;
&lt;li&gt; &lt;a dir=&quot;ltr&quot; href=&quot;http://c-completereference.blogspot.com/2010/12/operators.html&quot;&gt;OPERATORS&lt;/a&gt; &lt;/li&gt;
&lt;li&gt; &lt;a dir=&quot;ltr&quot; href=&quot;http://c-completereference.blogspot.com/2010/12/pc-graphics.html&quot;&gt;PC GRAPHICS&lt;/a&gt; &lt;/li&gt;
&lt;li&gt; &lt;a dir=&quot;ltr&quot; href=&quot;http://c-completereference.blogspot.com/2010/12/pointers-to-functions.html&quot;&gt;POINTERS TO FUNCTIONS&lt;/a&gt; &lt;/li&gt;
&lt;li&gt; &lt;a dir=&quot;ltr&quot; href=&quot;http://c-completereference.blogspot.com/2010/12/chapter-3.html&quot;&gt;PROGRAM CONTROL&lt;/a&gt; &lt;/li&gt;
&lt;li&gt; &lt;a dir=&quot;ltr&quot; href=&quot;http://c-completereference.blogspot.com/2010/12/program-control-statements.html&quot;&gt;PROGRAM CONTROL STATEMENTS&lt;/a&gt; &lt;/li&gt;
&lt;li&gt; &lt;a dir=&quot;ltr&quot; href=&quot;http://c-completereference.blogspot.com/2010/12/signal.html&quot;&gt;SIGNAL&lt;/a&gt; &lt;/li&gt;
&lt;li&gt; &lt;a dir=&quot;ltr&quot; href=&quot;http://c-completereference.blogspot.com/2010/12/sizeof.html&quot;&gt;SIZEOF&lt;/a&gt; &lt;/li&gt;
&lt;li&gt; &lt;a dir=&quot;ltr&quot; href=&quot;http://c-completereference.blogspot.com/2010/12/sorting-and-searching.html&quot;&gt;SORTING AND SEARCHING&lt;/a&gt; &lt;/li&gt;
&lt;li&gt; &lt;a dir=&quot;ltr&quot; href=&quot;http://c-completereference.blogspot.com/2010/12/chapter-9.html&quot;&gt;STANDARD INPUT/OUTPUT&lt;/a&gt; &lt;/li&gt;
&lt;li&gt; &lt;a dir=&quot;ltr&quot; href=&quot;http://c-completereference.blogspot.com/2010/12/strings.html&quot;&gt;STRINGS&lt;/a&gt; &lt;/li&gt;
&lt;li&gt; &lt;a dir=&quot;ltr&quot; href=&quot;http://c-completereference.blogspot.com/search/label/STRINGS%20AND%20ARRAYS&quot;&gt;STRINGS AND ARRAYS&lt;/a&gt; &lt;/li&gt;
&lt;li&gt; &lt;a dir=&quot;ltr&quot; href=&quot;http://c-completereference.blogspot.com/2010/12/structures.html&quot;&gt;STRUCTURES&lt;/a&gt; &lt;/li&gt;
&lt;li&gt; &lt;a dir=&quot;ltr&quot; href=&quot;http://c-completereference.blogspot.com/2010/12/chapter-11.html&quot;&gt;STRUCTURES AND UNIONS&lt;/a&gt; &lt;/li&gt;
&lt;li&gt; &lt;a dir=&quot;ltr&quot; href=&quot;http://c-completereference.blogspot.com/2010/12/text-handling.html&quot;&gt;TEXT HANDLING&lt;/a&gt; &lt;/li&gt;
&lt;li&gt; &lt;a dir=&quot;ltr&quot; href=&quot;http://c-completereference.blogspot.com/2010/12/importance-of-prototyping.html&quot;&gt;THE IMPORTANCE OF PROTOTYPING&lt;/a&gt; &lt;/li&gt;
&lt;li&gt; &lt;a dir=&quot;ltr&quot; href=&quot;http://c-completereference.blogspot.com/2010/12/time.html&quot;&gt;TIME&lt;/a&gt; &lt;/li&gt;
&lt;li&gt; &lt;a dir=&quot;ltr&quot; href=&quot;http://c-completereference.blogspot.com/2010/12/trigonometry-functions.html&quot;&gt;TRIGONOMETRY FUNCTIONS&lt;/a&gt; &lt;/li&gt;
&lt;li&gt; &lt;a dir=&quot;ltr&quot; href=&quot;http://c-completereference.blogspot.com/2010/12/using-link.html&quot;&gt;USING LINK&lt;/a&gt; &lt;/li&gt;
&lt;li&gt; &lt;a dir=&quot;ltr&quot; href=&quot;http://c-completereference.blogspot.com/2010/12/variable-argument-lists.html&quot;&gt;VARIABLE ARGUMENT LISTS&lt;/a&gt; &lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;&lt;ul&gt;&lt;dt style=&quot;text-align: center;&quot;&gt; &lt;/dt&gt;
&lt;/ul&gt;&lt;/div&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;SCRIPT LANGUAGE=&quot;JavaScript1.1&quot; SRC=&quot;http://bdv.bidvertiser.com/BidVertiser.dbm?pid=356752&amp;bid=1629957&quot; type=&quot;text/javascript&quot;&gt;&lt;/SCRIPT&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/650183537613822215/posts/default/2140238500764192236'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/650183537613822215/posts/default/2140238500764192236'/><link rel='alternate' type='text/html' href='http://c-completereference.blogspot.com/2011/03/if-you-want-prepare-for-international.html' title='If you Want Prepare For International Certificate In  C Language'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-650183537613822215.post-3913716411772671507</id><published>2010-12-18T08:42:00.000-08:00</published><updated>2010-12-18T08:42:19.107-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Programs In DYNAMIC ALLOCATION Of C"/><title type='text'>Programs In DYNAMIC ALLOCATION Of C</title><content type='html'>&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; color: black; font-family: &#39;Times New Roman&#39;; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;&lt;b&gt;C Tutorial&amp;nbsp; &lt;/b&gt;&lt;br /&gt;
&lt;b&gt; &lt;/b&gt;&lt;br /&gt;
&lt;b&gt;Programs In &lt;/b&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; color: black; font-family: &#39;Times New Roman&#39;; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;&lt;b&gt;DYNAMIC&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;ALLOCATION Of&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;b&gt; C&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Example Program No : 1&lt;/b&gt;&lt;b&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; color: black; font-family: &#39;Times New Roman&#39;; font-size: small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;&lt;br /&gt;
&lt;li&gt;Rewrite the example program STRUCT1.C from chapter 11 to dynamically allocate the two structures.&lt;/li&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;malloc.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
struct child &lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;&amp;nbsp; char initial;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* last name initial&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; */&lt;br /&gt;
&amp;nbsp;&amp;nbsp; int age;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* childs age&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;br /&gt;
&amp;nbsp;&amp;nbsp; int grade;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* childs grade in school */&lt;br /&gt;
} *boy, *girl;&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;&amp;nbsp; boy = (struct child *)malloc(sizeof(struct child));&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; boy-&amp;gt;initial = &#39;R&#39;;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; boy-&amp;gt;age = 15;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; boy-&amp;gt;grade = 75;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; girl = (struct child *)malloc(sizeof(struct child));&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; girl-&amp;gt;age = boy-&amp;gt;age - 1;&amp;nbsp; /* she is one year younger */&lt;br /&gt;
&amp;nbsp;&amp;nbsp; girl-&amp;gt;grade = 82;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; girl-&amp;gt;initial = &#39;H&#39;;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; printf(&quot;%c is %d years old and got a grade of %d\n&quot;,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; girl-&amp;gt;initial, girl-&amp;gt;age, girl-&amp;gt;grade);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; printf(&quot;%c is %d years old and got a grade of %d\n&quot;,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; boy-&amp;gt;initial, boy-&amp;gt;age, boy-&amp;gt;grade);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
/* Result of execution&lt;br /&gt;
&lt;br /&gt;
H is 14 years old and got a grade of 82&lt;br /&gt;
R is 15 years old and got a grade of 75&lt;br /&gt;
&lt;br /&gt;
*/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; color: black; font-family: &#39;Times New Roman&#39;; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;&lt;b&gt;Example Program No :2&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; color: black; font-family: &#39;Times New Roman&#39;; font-size: small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;&lt;br /&gt;
&lt;li&gt;Rewrite the example program STRUCT2.C from chapter 11 to dynamically allocate the 12 structures.&lt;/li&gt;&lt;br /&gt;
&lt;/span&gt;&amp;nbsp;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;malloc.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
struct child &lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;&amp;nbsp; char initial;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; int age;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; int grade;&lt;br /&gt;
} *kids[12];&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
int index;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; for (index = 0 ; index &amp;lt; 12 ; index++) &lt;br /&gt;
&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; kids[index] = (struct child *)malloc(sizeof(struct child));&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; kids[index]-&amp;gt;initial = &#39;A&#39; + index;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; kids[index]-&amp;gt;age = 16;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; kids[index]-&amp;gt;grade = 84;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; kids[3]-&amp;gt;age = kids[5]-&amp;gt;age = 17;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; kids[2]-&amp;gt;grade = kids[6]-&amp;gt;grade = 92;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; kids[4]-&amp;gt;grade = 57;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; *kids[10] = *kids[4];&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; /* Structure assignment&amp;nbsp; */&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; for (index = 0 ; index &amp;lt; 12 ; index++)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&quot;%c is %d years old and got a grade of %d\n&quot;,&lt;br /&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; kids[index]-&amp;gt;initial, kids[index]-&amp;gt;age,&lt;br /&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; kids[index]-&amp;gt;grade);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
/* Result of execution&lt;br /&gt;
&lt;br /&gt;
A is 16 years old and got a grade of 84&lt;br /&gt;
B is 16 years old and got a grade of 84&lt;br /&gt;
C is 16 years old and got a grade of 92&lt;br /&gt;
D is 17 years old and got a grade of 84&lt;br /&gt;
E is 16 years old and got a grade of 57&lt;br /&gt;
F is 17 years old and got a grade of 84&lt;br /&gt;
G is 16 years old and got a grade of 92&lt;br /&gt;
H is 16 years old and got a grade of 84&lt;br /&gt;
I is 16 years old and got a grade of 84&lt;br /&gt;
J is 16 years old and got a grade of 84&lt;br /&gt;
E is 16 years old and got a grade of 57&lt;br /&gt;
L is 16 years old and got a grade of 84&lt;br /&gt;
&lt;br /&gt;
*/&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;SCRIPT LANGUAGE=&quot;JavaScript1.1&quot; SRC=&quot;http://bdv.bidvertiser.com/BidVertiser.dbm?pid=356752&amp;bid=1629957&quot; type=&quot;text/javascript&quot;&gt;&lt;/SCRIPT&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/650183537613822215/posts/default/3913716411772671507'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/650183537613822215/posts/default/3913716411772671507'/><link rel='alternate' type='text/html' href='http://c-completereference.blogspot.com/2010/12/programs-in-dynamic-allocation-of-c.html' title='Programs In DYNAMIC ALLOCATION Of C'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-650183537613822215.post-1457444182452867023</id><published>2010-12-18T08:40:00.000-08:00</published><updated>2010-12-18T08:40:09.701-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Programs In STRUCTURES AND UNIONS Of C"/><title type='text'>Programs In STRUCTURES AND UNIONS Of C</title><content type='html'>&lt;b&gt;C Tutorial&amp;nbsp; &lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Programs In &lt;/b&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; color: black; font-family: &#39;Times New Roman&#39;; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;&lt;b&gt;STRUCTURES&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;AND&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;UNIONS Of&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;b&gt; C&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Example Program No : 1&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; color: black; font-family: &#39;Times New Roman&#39;; font-size: small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;&lt;br /&gt;
&lt;li&gt;Define a named structure containing a string for a name, an integer for feet, and another for arms. Use the new type to define an array of about 6 items. Fill the fields with data and print them out as follows.&lt;/li&gt;&lt;br /&gt;
&lt;dl&gt;&lt;pre&gt;A human being has 2 legs and 2 arms.
     A dog has 4 legs and 0 arms.
     A television set has 4 legs and 0 arms.
     A chair has 4 legs and 2 arms.&lt;/pre&gt;&lt;pre&gt;&lt;/pre&gt;&lt;pre&gt;#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;string.h&amp;gt;

struct 
{
   char what[25];
   int legs, arms;
} object[6];

int main()
{
int index;

   strcpy(object[0].what, &quot;human being&quot;);
   object[0].legs = 2;
   object[0].arms = 2;

   strcpy(object[1].what, &quot;dog&quot;);
   object[1].legs = 4;
   object[1].arms = 0;

   strcpy(object[2].what, &quot;television set&quot;);
   object[2].legs = 4;
   object[2].arms = 0;

   strcpy(object[3].what, &quot;chair&quot;);
   object[3].legs = 4;
   object[3].arms = 2;

   strcpy(object[4].what, &quot;centipede&quot;);
   object[4].legs = 100;
   object[4].arms = 0;

   strcpy(object[5].what, &quot;spider&quot;);
   object[5].legs = 6;
   object[5].arms = 0;

   for(index = 0 ; index &amp;lt; 6 ; index++) 
   {
      printf(&quot;A %s has %d legs and %d arms.\n&quot;, object[index].what,
                  object[index].legs, object[index].arms);
   }

   return 0;
}



/* Result of execution

A human being has 2 legs and 2 arms.
A dog has 4 legs and 0 arms.
A television set has 4 legs and 0 arms.
A chair has 4 legs and 2 arms.
A centipede has 100 legs and 0 arms.
A spider has 6 legs and 0 arms.

*/&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;/pre&gt;&lt;pre&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;b&gt;Example Program No : 2&lt;/b&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/dl&gt;&lt;li&gt;Rewrite exercise 1 using a pointer to print the data out.&lt;/li&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;string.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
struct &lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;&amp;nbsp; char what[25];&lt;br /&gt;
&amp;nbsp;&amp;nbsp; int legs, arms;&lt;br /&gt;
} object[6], *point;&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
int index;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; strcpy(object[0].what, &quot;human being&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; object[0].legs = 2;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; object[0].arms = 2;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; strcpy(object[1].what, &quot;dog&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; object[1].legs = 4;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; object[1].arms = 0;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; strcpy(object[2].what, &quot;television set&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; object[2].legs = 4;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; object[2].arms = 0;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; strcpy(object[3].what, &quot;chair&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; object[3].legs = 4;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; object[3].arms = 2;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; strcpy(object[4].what, &quot;centipede&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; object[4].legs = 100;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; object[4].arms = 0;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; strcpy(object[5].what, &quot;spider&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; object[5].legs = 6;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; object[5].arms = 0;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; point = object;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; for(index = 0 ; index &amp;lt; 6 ; index++) &lt;br /&gt;
&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&quot;A %s has %d legs and %d arms.\n&quot;, point-&amp;gt;what,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; point-&amp;gt;legs, point-&amp;gt;arms);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; point++;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
/* Result of execution&lt;br /&gt;
&lt;br /&gt;
A human being has 2 legs and 2 arms.&lt;br /&gt;
A dog has 4 legs and 0 arms.&lt;br /&gt;
A television set has 4 legs and 0 arms.&lt;br /&gt;
A chair has 4 legs and 2 arms.&lt;br /&gt;
A centipede has 100 legs and 0 arms.&lt;br /&gt;
A spider has 6 legs and 0 arms.&lt;br /&gt;
&lt;br /&gt;
*/&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; color: black; font-family: &#39;Times New Roman&#39;; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;&lt;b&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;SCRIPT LANGUAGE=&quot;JavaScript1.1&quot; SRC=&quot;http://bdv.bidvertiser.com/BidVertiser.dbm?pid=356752&amp;bid=1629957&quot; type=&quot;text/javascript&quot;&gt;&lt;/SCRIPT&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/650183537613822215/posts/default/1457444182452867023'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/650183537613822215/posts/default/1457444182452867023'/><link rel='alternate' type='text/html' href='http://c-completereference.blogspot.com/2010/12/programs-in-structures-and-unions-of-c.html' title='Programs In STRUCTURES AND UNIONS Of C'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-650183537613822215.post-487226790058613798</id><published>2010-12-18T08:37:00.000-08:00</published><updated>2010-12-18T08:37:17.527-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Programs In File I/O of C"/><title type='text'>Programs In File I/O of C</title><content type='html'>&lt;b&gt;C Tutorial&amp;nbsp; &lt;/b&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Programs In File I/O of C&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Example Program No : 1&lt;/b&gt; &lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; color: black; font-family: &#39;Times New Roman&#39;; font-size: small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;&lt;br /&gt;
&lt;li&gt;Write a program that will prompt for a filename for an input file, prompt for a filename for a write file, and open both plus a file to the printer. Enter a loop that will read a character, and output it to the file, the printer, and the monitor. Stop at EOF.&lt;/li&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
FILE *infile, *outfile, *printer;&lt;br /&gt;
char infilename[25], outfilename[25];&lt;br /&gt;
int&amp;nbsp; c;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; printf(&quot;Enter input file name ----&amp;gt; &quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; scanf(&quot;%s&quot;, infilename);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; infile = fopen(infilename, &quot;r&quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; printf(&quot;Enter output file name ---&amp;gt; &quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; scanf(&quot;%s&quot;, outfilename);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; outfile = fopen(outfilename, &quot;w&quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; printer = fopen(&quot;PRN&quot;, &quot;w&quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; do &lt;br /&gt;
&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; c = getc(infile);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (c != EOF) &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; putchar(c);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; putc(c, outfile);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; putc(c, printer);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp; } while (c != EOF);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; fclose(printer);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; fclose(infile);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; fclose(outfile);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
/* Result of execution&lt;br /&gt;
&lt;br /&gt;
(This program writes to the printer, a file, and the monitor.)&lt;br /&gt;
&lt;br /&gt;
*/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Example Program No :2&lt;/b&gt; &lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; color: black; font-family: &#39;Times New Roman&#39;; font-size: small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;&lt;br /&gt;
&lt;li&gt;Prompt for a filename to read. Read the file a line at a time and display it on the monitor with line numbers.&lt;/li&gt;&lt;br /&gt;
&lt;/span&gt;&amp;nbsp;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
FILE *infile;&lt;br /&gt;
char c, infilename[25], inputline[100];&lt;br /&gt;
int line = 1;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; printf(&quot;Enter input file name ----&amp;gt; &quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; scanf(&quot;%s&quot;, infilename);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; infile = fopen(infilename, &quot;r&quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; printf(&quot;%5d&quot;, line);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; do &lt;br /&gt;
&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; c = fgets(inputline, 100, infile);&amp;nbsp; /* read a line */&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (c != NULL) &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&quot;%5d %s&quot;, line, inputline);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; line++;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp; } while (c != NULL);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; fclose(infile);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
/* Result of execution&lt;br /&gt;
&lt;br /&gt;
(You will get a listing of the file on the monitor with line numbers)&lt;br /&gt;
&lt;br /&gt;
*/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Example Program No : 3&lt;/b&gt; &lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; color: black; font-family: &#39;Times New Roman&#39;; font-size: small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;&lt;br /&gt;
&lt;li&gt;Modify ANYFILE.C to test if the file exists and print a message if it doesn&#39;t. Use a method similar to that used in READCHAR.C.&lt;/li&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
FILE *fp1;&lt;br /&gt;
char oneword[100], filename[25];&lt;br /&gt;
char *c;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; printf(&quot;Enter filename -&amp;gt; &quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; scanf(&quot;%s&quot;, filename);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* read the desired filename */&lt;br /&gt;
&amp;nbsp;&amp;nbsp; fp1 = fopen(filename, &quot;r&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; if (fp1 == NULL)&lt;br /&gt;
&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&quot;File doesn&#39;t exist\n&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; exit (1);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp; else &lt;br /&gt;
&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; c = fgets(oneword, 100, fp1); /* get a line from the file */&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (c != NULL)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&quot;%s&quot;, oneword);&amp;nbsp;&amp;nbsp;&amp;nbsp; /* display it on the monitor */&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } while (c != NULL);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* repeat until NULL&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; */&lt;br /&gt;
&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp; fclose(fp1);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
/* Result of execution&lt;br /&gt;
&lt;br /&gt;
(The output depends on weather you type in a good filename.)&lt;br /&gt;
&lt;br /&gt;
*/&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;SCRIPT LANGUAGE=&quot;JavaScript1.1&quot; SRC=&quot;http://bdv.bidvertiser.com/BidVertiser.dbm?pid=356752&amp;bid=1629957&quot; type=&quot;text/javascript&quot;&gt;&lt;/SCRIPT&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/650183537613822215/posts/default/487226790058613798'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/650183537613822215/posts/default/487226790058613798'/><link rel='alternate' type='text/html' href='http://c-completereference.blogspot.com/2010/12/programs-in-file-io-of-c.html' title='Programs In File I/O of C'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-650183537613822215.post-1611902502697901858</id><published>2010-12-18T08:34:00.000-08:00</published><updated>2010-12-18T08:34:55.387-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Programs In I/O Of C"/><title type='text'>Programs In I/O Of C</title><content type='html'>&lt;b&gt;C Tutorial&amp;nbsp; &lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;Programs In I/O Of C&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Example Program No : 1&lt;/b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; color: black; font-family: &#39;Times New Roman&#39;; font-size: small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;&lt;br /&gt;
&lt;li&gt;Write a program to read in a character using a loop, and display the character in its normal&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;b&gt;char&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/b&gt;form. Also display it as a decimal number. Check for a dollar sign to use as the stop character. Use the&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;b&gt;_getch()&lt;/b&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;form of input so it will print immediately. Hit some of the special keys, such as function keys, when you run the program for some surprises. You will get two inputs from the special keys, the first being a zero which is the indication to the system that a special key was hit.&lt;/li&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;conio.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
char input_char;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; printf(&quot;Hit any key - to stop hit a $\n&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; do &lt;br /&gt;
&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; input_char = _getch();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&quot;Input character is %c, numerical value is %3d\n&quot;,&lt;br /&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; input_char, input_char);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; } while (input_char != &#39;$&#39;);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
/*&amp;nbsp; Result of execution&lt;br /&gt;
&lt;br /&gt;
Hit any key - to stop hit a $&lt;br /&gt;
Input character is A, numerical value is&amp;nbsp; 65&lt;br /&gt;
Input character is B, numerical value is&amp;nbsp; 66&lt;br /&gt;
...&lt;br /&gt;
(The display depends on the input keys hit)&lt;br /&gt;
&lt;br /&gt;
*/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&lt;b&gt;Example Program No :2&lt;/b&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; color: black; font-family: &#39;Times New Roman&#39;; font-size: small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;&lt;br /&gt;
&lt;li&gt;Add a character string to SINGLEIO.C and store the input characters in the string. When the X is detected, add a terminating null to the string and print out the string with a&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;b&gt;printf()&lt;/b&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;function call.&lt;/li&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;conio.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
char storage[80];&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
char c;&lt;br /&gt;
int index = 0;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; printf(&quot;Enter any characters, terminate program with X\n&quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; do &lt;br /&gt;
&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; c = _getch();&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* get a character&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;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (index &amp;lt; 79)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* limit it to 79 characters&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; */&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; storage[index] = c;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; index++;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; putchar(c);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* display the hit key&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;br /&gt;
&amp;nbsp;&amp;nbsp; } while (c != &#39;X&#39;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; storage[index] = 0;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; printf(&quot;%s\n&quot;, storage);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; printf(&quot;\nEnd of program.\n&quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
/* Result of execution&lt;br /&gt;
&lt;br /&gt;
Enter any characters, terminate program with X&lt;br /&gt;
&lt;br /&gt;
(The output depends on the characters you type in.)&lt;br /&gt;
&lt;br /&gt;
End of program.&lt;br /&gt;
&lt;br /&gt;
*/&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;SCRIPT LANGUAGE=&quot;JavaScript1.1&quot; SRC=&quot;http://bdv.bidvertiser.com/BidVertiser.dbm?pid=356752&amp;bid=1629957&quot; type=&quot;text/javascript&quot;&gt;&lt;/SCRIPT&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/650183537613822215/posts/default/1611902502697901858'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/650183537613822215/posts/default/1611902502697901858'/><link rel='alternate' type='text/html' href='http://c-completereference.blogspot.com/2010/12/programs-in-io-of-c.html' title='Programs In I/O Of C'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-650183537613822215.post-1721636651461264222</id><published>2010-12-18T08:32:00.000-08:00</published><updated>2010-12-18T08:32:29.083-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Programs In Pointer  Of C"/><title type='text'>Programs In Pointer  Of C</title><content type='html'>&lt;b&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; color: black; font-family: &#39;Times New Roman&#39;; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;C Tutorial&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;b&gt;Programs In &lt;span style=&quot;font-size: large;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; color: black; font-family: &#39;Times New Roman&#39;; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;Pointer&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&amp;nbsp; Of C&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Example Program No : 1&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; color: black; font-family: &#39;Times New Roman&#39;; font-size: small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;A variable name with an ampersand in front of it defines the address of the variable and therefore points to the variable. You can therefore read line nine as &quot;&lt;b&gt;pt1&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/b&gt;is assigned the value of the address of&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;b&gt;index&lt;/b&gt;&quot;.&lt;/span&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; color: black; font-family: &#39;Times New Roman&#39;; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; color: black; font-family: &#39;Times New Roman&#39;; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; color: black; font-family: &#39;Times New Roman&#39;; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;string.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
int index;&lt;br /&gt;
char stuff[20], *pt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; strcpy(stuff, &quot;This is a neat test.&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; pt = stuff;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; for(index = 0 ; index &amp;lt; 20 ; index++) &lt;br /&gt;
&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&quot;A character is ---&amp;gt; %c\n&quot;, *pt);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pt++;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
/* Result of execution&lt;br /&gt;
&lt;br /&gt;
A character is ---&amp;gt; T&lt;br /&gt;
A character is ---&amp;gt; h&lt;br /&gt;
A character is ---&amp;gt; i&lt;br /&gt;
A character is ---&amp;gt; s&lt;br /&gt;
A character is ---&amp;gt;&lt;br /&gt;
A character is ---&amp;gt; i&lt;br /&gt;
A character is ---&amp;gt; s&lt;br /&gt;
A character is ---&amp;gt;&lt;br /&gt;
A character is ---&amp;gt; a&lt;br /&gt;
A character is ---&amp;gt;&lt;br /&gt;
A character is ---&amp;gt; n&lt;br /&gt;
A character is ---&amp;gt; e&lt;br /&gt;
A character is ---&amp;gt; a&lt;br /&gt;
A character is ---&amp;gt; t&lt;br /&gt;
A character is ---&amp;gt;&lt;br /&gt;
A character is ---&amp;gt; t&lt;br /&gt;
A character is ---&amp;gt; e&lt;br /&gt;
A character is ---&amp;gt; s&lt;br /&gt;
A character is ---&amp;gt; t&lt;br /&gt;
A character is ---&amp;gt; .&lt;br /&gt;
&lt;br /&gt;
*/&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; color: black; font-family: &#39;Times New Roman&#39;; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;Example Program No : 2&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; color: black; font-family: &#39;Times New Roman&#39;; font-size: small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;A pointer with a star in front of it refers to the value of the variable pointed to by the pointer. Line twelve of the program can be read as &quot;The stored (starred) value to which the pointer&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;b&gt;pt1&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/b&gt;points is assigned the value 13&quot;. This is commonly referred to as dereferencing the pointer. Now you can see why it is convenient to think of the asterisk as a star, it sort of sounds like the word store.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; color: black; font-family: &#39;Times New Roman&#39;; font-size: small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; color: black; font-family: &#39;Times New Roman&#39;; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;string.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
int index;&lt;br /&gt;
char stuff[20], *pt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; strcpy(stuff, &quot;This is a neat test.&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; pt = stuff + 19;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; for(index = 0 ; index &amp;lt; 20 ; index++) &lt;br /&gt;
&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&quot;A character is ---&amp;gt; %c\n&quot;, *pt);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pt--;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
/* Result of execution&lt;br /&gt;
&lt;br /&gt;
A character is ---&amp;gt; .&lt;br /&gt;
A character is ---&amp;gt; t&lt;br /&gt;
A character is ---&amp;gt; s&lt;br /&gt;
A character is ---&amp;gt; e&lt;br /&gt;
A character is ---&amp;gt; t&lt;br /&gt;
A character is ---&amp;gt;&lt;br /&gt;
A character is ---&amp;gt; t&lt;br /&gt;
A character is ---&amp;gt; a&lt;br /&gt;
A character is ---&amp;gt; e&lt;br /&gt;
A character is ---&amp;gt; n&lt;br /&gt;
A character is ---&amp;gt;&lt;br /&gt;
A character is ---&amp;gt; a&lt;br /&gt;
A character is ---&amp;gt;&lt;br /&gt;
A character is ---&amp;gt; s&lt;br /&gt;
A character is ---&amp;gt; i&lt;br /&gt;
A character is ---&amp;gt;&lt;br /&gt;
A character is ---&amp;gt; s&lt;br /&gt;
A character is ---&amp;gt; i&lt;br /&gt;
A character is ---&amp;gt; h&lt;br /&gt;
A character is ---&amp;gt; T&lt;br /&gt;
&lt;br /&gt;
*/&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;SCRIPT LANGUAGE=&quot;JavaScript1.1&quot; SRC=&quot;http://bdv.bidvertiser.com/BidVertiser.dbm?pid=356752&amp;bid=1629957&quot; type=&quot;text/javascript&quot;&gt;&lt;/SCRIPT&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/650183537613822215/posts/default/1721636651461264222'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/650183537613822215/posts/default/1721636651461264222'/><link rel='alternate' type='text/html' href='http://c-completereference.blogspot.com/2010/12/programs-in-pointer-of-c.html' title='Programs In Pointer  Of C'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-650183537613822215.post-251088884894697632</id><published>2010-12-18T08:29:00.000-08:00</published><updated>2010-12-18T08:29:24.451-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Programs In STRINGS AND ARRAYS Of C"/><title type='text'>Programs In STRINGS AND ARRAYS Of C</title><content type='html'>&lt;b&gt;C Tutorial&amp;nbsp; &lt;/b&gt;&lt;br /&gt;
&lt;b&gt; &lt;/b&gt;&lt;br /&gt;
&lt;b&gt;Programs In &lt;/b&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; color: black; font-family: &#39;Times New Roman&#39;; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;&lt;b&gt;STRINGS&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;AND&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;ARRAYS Of C&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Example Program No : 1&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; color: black; font-family: &#39;Times New Roman&#39;; font-size: small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;Write a program with three short strings, about 6 characters each, and use&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;b&gt;strcpy()&lt;/b&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;to copy the string literals &quot;one&quot;, &quot;two&quot;, and &quot;three&quot; into them. Concatenate the three strings into one larger string defined with 30 characters and print the result out 10 times.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; color: black; font-family: &#39;Times New Roman&#39;; font-size: small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;#include &quot;stdio.h&quot;&lt;br /&gt;
#include &quot;string.h&quot;&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
int index;&lt;br /&gt;
char string1[6], string2[6], string3[6], all_three[18];&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; strcpy(string1, &quot;one&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; strcpy(string2, &quot;two&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; strcpy(string3, &quot;three&quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; strcpy(all_three, string1);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; strcat(all_three, &quot; &quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; strcat(all_three, string2);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; strcat(all_three, &quot; &quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; strcat(all_three, string3);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; for(index = 0 ; index &amp;lt; 10 ; index = index + 1)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&quot;The final string is ---&amp;gt; %s\n&quot;, all_three);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
/* Result of execution&lt;br /&gt;
&lt;br /&gt;
The final string is ---&amp;gt; one two three&lt;br /&gt;
The final string is ---&amp;gt; one two three&lt;br /&gt;
The final string is ---&amp;gt; one two three&lt;br /&gt;
The final string is ---&amp;gt; one two three&lt;br /&gt;
The final string is ---&amp;gt; one two three&lt;br /&gt;
The final string is ---&amp;gt; one two three&lt;br /&gt;
The final string is ---&amp;gt; one two three&lt;br /&gt;
The final string is ---&amp;gt; one two three&lt;br /&gt;
The final string is ---&amp;gt; one two three&lt;br /&gt;
The final string is ---&amp;gt; one two three&lt;br /&gt;
&lt;br /&gt;
*/&lt;br /&gt;
&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;b&gt;Example Program No : 2&lt;/b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; color: black; font-family: &#39;Times New Roman&#39;; font-size: small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; color: black; font-family: &#39;Times New Roman&#39;; font-size: small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;Define two integer arrays, each 10 elements long, called&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;b&gt;array1&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/b&gt;and&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;b&gt;array2&lt;/b&gt;. Using a loop, put some kind of nonsense data in each and add them term for term into another 10 element array named&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;b&gt;arrays&lt;/b&gt;. Finally, print all results in a table with an index number.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; color: black; font-family: &#39;Times New Roman&#39;; font-size: small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;&amp;nbsp;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
int index, array1[10], array2[10], arrays[10];&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; for(index = 0 ; index &amp;lt; 10 ; index = index + 1) &lt;br /&gt;
&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; array1[index] = 2 + 2 * index;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; array2[index] = 10 * (index + 1);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; for(index = 0 ; index &amp;lt; 10 ; index = index + 1)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arrays[index] = array1[index] + array2[index];&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; for(index = 0 ; index &amp;lt; 10 ; index = index + 1)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&quot;%4d %4d + %4d = %4d\n&quot;, (index + 1), array1[index],&lt;br /&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; array2[index], arrays[index]);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
/* Result of execution&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp; 2 +&amp;nbsp;&amp;nbsp; 10 =&amp;nbsp;&amp;nbsp; 12&lt;br /&gt;
&amp;nbsp;&amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp; 4 +&amp;nbsp;&amp;nbsp; 20 =&amp;nbsp;&amp;nbsp; 24&lt;br /&gt;
&amp;nbsp;&amp;nbsp; 3&amp;nbsp;&amp;nbsp;&amp;nbsp; 6 +&amp;nbsp;&amp;nbsp; 30 =&amp;nbsp;&amp;nbsp; 36&lt;br /&gt;
&amp;nbsp;&amp;nbsp; 4&amp;nbsp;&amp;nbsp;&amp;nbsp; 8 +&amp;nbsp;&amp;nbsp; 40 =&amp;nbsp;&amp;nbsp; 48&lt;br /&gt;
&amp;nbsp;&amp;nbsp; 5&amp;nbsp;&amp;nbsp; 10 +&amp;nbsp;&amp;nbsp; 50 =&amp;nbsp;&amp;nbsp; 60&lt;br /&gt;
&amp;nbsp;&amp;nbsp; 6&amp;nbsp;&amp;nbsp; 12 +&amp;nbsp;&amp;nbsp; 60 =&amp;nbsp;&amp;nbsp; 72&lt;br /&gt;
&amp;nbsp;&amp;nbsp; 7&amp;nbsp;&amp;nbsp; 14 +&amp;nbsp;&amp;nbsp; 70 =&amp;nbsp;&amp;nbsp; 84&lt;br /&gt;
&amp;nbsp;&amp;nbsp; 8&amp;nbsp;&amp;nbsp; 16 +&amp;nbsp;&amp;nbsp; 80 =&amp;nbsp;&amp;nbsp; 96&lt;br /&gt;
&amp;nbsp;&amp;nbsp; 9&amp;nbsp;&amp;nbsp; 18 +&amp;nbsp;&amp;nbsp; 90 =&amp;nbsp; 108&lt;br /&gt;
&amp;nbsp; 10&amp;nbsp;&amp;nbsp; 20 +&amp;nbsp; 100 =&amp;nbsp; 120&lt;br /&gt;
&lt;br /&gt;
*/&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; color: black; font-family: &#39;Times New Roman&#39;; font-size: small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;b&gt;Example Program No :3&lt;/b&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; color: black; font-family: &#39;Times New Roman&#39;; font-size: small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;&lt;/span&gt;Define a string of some selected length, assign a word or phrase to it, and print it out as a string, then print it out as individual characters. Finally, print it out backwards by using a&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;b&gt;for&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/b&gt;loop with a decrementing third term. A useful function for the first term of the&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;b&gt;for&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/b&gt;loop is&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;b&gt;strlen()&lt;/b&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;which returns the length of the string by counting characters up to, but not including, the terminating null.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;string.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
char my_string[20] = &quot;C is neat!&quot;;&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
int index;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; printf(&quot;%s\n&quot;, my_string);&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp; for (index = 0 ; my_string[index] ; index = index + 1)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&quot;%c&quot;, my_string[index]);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; printf(&quot;\n&quot;);&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp; for(index = strlen(my_string) ; index &amp;gt; 0 ; index = index - 1)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&quot;%c&quot;, my_string[index - 1]);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; printf(&quot;\n&quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
/* Result of execution&lt;br /&gt;
&lt;br /&gt;
C is neat!&lt;br /&gt;
C is neat!&lt;br /&gt;
!taen si C&lt;br /&gt;
&lt;br /&gt;
*/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; color: black; font-family: &#39;Times New Roman&#39;; font-size: small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; color: black; font-family: &#39;Times New Roman&#39;; font-size: small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; color: black; font-family: &#39;Times New Roman&#39;; font-size: small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;b&gt; &lt;/b&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; color: black; font-family: &#39;Times New Roman&#39;; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;&lt;b&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;SCRIPT LANGUAGE=&quot;JavaScript1.1&quot; SRC=&quot;http://bdv.bidvertiser.com/BidVertiser.dbm?pid=356752&amp;bid=1629957&quot; type=&quot;text/javascript&quot;&gt;&lt;/SCRIPT&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/650183537613822215/posts/default/251088884894697632'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/650183537613822215/posts/default/251088884894697632'/><link rel='alternate' type='text/html' href='http://c-completereference.blogspot.com/2010/12/programs-in-strings-and-arrays-of-c.html' title='Programs In STRINGS AND ARRAYS Of C'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-650183537613822215.post-4598179693301365450</id><published>2010-12-18T08:26:00.000-08:00</published><updated>2010-12-18T08:26:44.468-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Programs In C Preprocessor"/><title type='text'>Programs In C Preprocessor</title><content type='html'>&lt;b&gt;C Tutorial&amp;nbsp; &lt;/b&gt;&lt;br /&gt;
&lt;b&gt; &lt;/b&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;Programs In C&lt;/b&gt; &lt;b&gt;Preprocessor&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Example Program No : 1&lt;/b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; color: black; font-family: &#39;Times New Roman&#39;; font-size: small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; color: black; font-family: &#39;Times New Roman&#39;; font-size: small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;Write a program to count from 7 to -5 by counting down. Use&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;b&gt;#define&lt;/b&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;statements to define the limits. (Hint, you will need to use a decrementing variable in the third part of the&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;b&gt;for&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/b&gt;loop control.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; color: black; font-family: &#39;Times New Roman&#39;; font-size: small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;&amp;nbsp;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#define START&amp;nbsp; 7&lt;br /&gt;
#define END&amp;nbsp;&amp;nbsp; -5&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
int index;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; for(index = START ; index &amp;gt;= END ; index = index - 1)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&quot;The value of the count is now %2d\n&quot;, index);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
/* Result of execution&lt;br /&gt;
&lt;br /&gt;
The value of the count is now&amp;nbsp; 7&lt;br /&gt;
The value of the count is now&amp;nbsp; 6&lt;br /&gt;
The value of the count is now&amp;nbsp; 5&lt;br /&gt;
The value of the count is now&amp;nbsp; 4&lt;br /&gt;
The value of the count is now&amp;nbsp; 3&lt;br /&gt;
The value of the count is now&amp;nbsp; 2&lt;br /&gt;
The value of the count is now&amp;nbsp; 1&lt;br /&gt;
The value of the count is now&amp;nbsp; 0&lt;br /&gt;
The value of the count is now -1&lt;br /&gt;
The value of the count is now -2&lt;br /&gt;
The value of the count is now -3&lt;br /&gt;
The value of the count is now -4&lt;br /&gt;
The value of the count is now -5&lt;br /&gt;
&lt;br /&gt;
*/&lt;br /&gt;
&lt;/span&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;SCRIPT LANGUAGE=&quot;JavaScript1.1&quot; SRC=&quot;http://bdv.bidvertiser.com/BidVertiser.dbm?pid=356752&amp;bid=1629957&quot; type=&quot;text/javascript&quot;&gt;&lt;/SCRIPT&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/650183537613822215/posts/default/4598179693301365450'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/650183537613822215/posts/default/4598179693301365450'/><link rel='alternate' type='text/html' href='http://c-completereference.blogspot.com/2010/12/programs-in-c-preprocessor.html' title='Programs In C Preprocessor'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-650183537613822215.post-1445444687111180441</id><published>2010-12-18T08:24:00.001-08:00</published><updated>2010-12-18T08:24:46.440-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Programs In FUNCTIONS  VARIABLES AND PROTOTYPES of C"/><title type='text'>Programs In FUNCTIONS, VARIABLES, AND PROTOTYPES of C</title><content type='html'>&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; color: black; font-family: &#39;Times New Roman&#39;; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;&lt;b&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;b&gt;C Tutorial&amp;nbsp; &lt;/b&gt;&lt;br /&gt;
&lt;b&gt; &lt;/b&gt;&lt;br /&gt;
&lt;b&gt;Programs In &lt;/b&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; color: black; font-family: &#39;Times New Roman&#39;; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;&lt;b&gt;FUNCTIONS,&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;VARIABLES, AND&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;PROTOTYPES&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;b&gt; &lt;span style=&quot;font-size: large;&quot;&gt;of&lt;/span&gt; C&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Example Program No : 1&lt;/b&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; color: black; font-family: &#39;Times New Roman&#39;; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; color: black; font-family: &#39;Times New Roman&#39;; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; color: black; font-family: &#39;Times New Roman&#39;; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;&lt;/span&gt;&lt;/span&gt;To Rewrite TEMPCONV.C from an earlier chapter, and move the temperature calculation to a function.&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; color: black; font-family: &#39;Times New Roman&#39;; font-size: small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; color: black; font-family: &#39;Times New Roman&#39;; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;/****************************************************************/&lt;br /&gt;
/*&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&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;br /&gt;
/*&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; This is a temperature conversion program written in&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; */&lt;br /&gt;
/*&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; the C programming language. This program generates&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; */&lt;br /&gt;
/*&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; and displays a table of farenheit and centigrade&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; */&lt;br /&gt;
/*&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; temperatures, and lists the freezing and boiling&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; */&lt;br /&gt;
/*&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; of water.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; */&lt;br /&gt;
/*&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&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;br /&gt;
/****************************************************************/&lt;br /&gt;
&lt;br /&gt;
#include &quot;stdio.h&quot;&lt;br /&gt;
int tempcalc(itn centtemp);&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
int count;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* a loop control variable&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;br /&gt;
int farenheit;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* the temperature in farenheit degrees&amp;nbsp; */&lt;br /&gt;
int centigrade;&amp;nbsp;&amp;nbsp; /* the temperature in centigrade degrees */&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; printf(&quot;Centigrade to Farenheit temperature table\n\n&quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; for(count = -2 ; count &amp;lt;= 12 ; count = count + 1)&lt;br /&gt;
&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; centigrade = 10 * count;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; farenheit = tempcalc(centigrade);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&quot;&amp;nbsp; C =%4d&amp;nbsp;&amp;nbsp; F =%4d&amp;nbsp; &quot;, centigrade, farenheit);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (centigrade == 0)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&quot; Freezing point of water&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (centigrade == 100)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&quot; Boiling point of water&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&quot;\n&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; } /* end of for loop */&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
int tempcalc(int centtemp)&lt;br /&gt;
{&lt;br /&gt;
int faren;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; faren = 32 + (centtemp * 9)/5;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; return (faren);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
/* Result of execution&lt;br /&gt;
&lt;br /&gt;
Centigrade to Farenheit temperature table&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; C = -20&amp;nbsp;&amp;nbsp; F =&amp;nbsp; -4&lt;br /&gt;
&amp;nbsp; C = -10&amp;nbsp;&amp;nbsp; F =&amp;nbsp; 14&lt;br /&gt;
&amp;nbsp; C =&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp; F =&amp;nbsp; 32&amp;nbsp;&amp;nbsp; Freezing point of water&lt;br /&gt;
&amp;nbsp; C =&amp;nbsp; 10&amp;nbsp;&amp;nbsp; F =&amp;nbsp; 50&lt;br /&gt;
&amp;nbsp; C =&amp;nbsp; 20&amp;nbsp;&amp;nbsp; F =&amp;nbsp; 68&lt;br /&gt;
&amp;nbsp; C =&amp;nbsp; 30&amp;nbsp;&amp;nbsp; F =&amp;nbsp; 86&lt;br /&gt;
&amp;nbsp; C =&amp;nbsp; 40&amp;nbsp;&amp;nbsp; F = 104&lt;br /&gt;
&amp;nbsp; C =&amp;nbsp; 50&amp;nbsp;&amp;nbsp; F = 122&lt;br /&gt;
&amp;nbsp; C =&amp;nbsp; 60&amp;nbsp;&amp;nbsp; F = 140&lt;br /&gt;
&amp;nbsp; C =&amp;nbsp; 70&amp;nbsp;&amp;nbsp; F = 158&lt;br /&gt;
&amp;nbsp; C =&amp;nbsp; 80&amp;nbsp;&amp;nbsp; F = 176&lt;br /&gt;
&amp;nbsp; C =&amp;nbsp; 90&amp;nbsp;&amp;nbsp; F = 194&lt;br /&gt;
&amp;nbsp; C = 100&amp;nbsp;&amp;nbsp; F = 212&amp;nbsp;&amp;nbsp; Boiling point of water&lt;br /&gt;
&amp;nbsp; C = 110&amp;nbsp;&amp;nbsp; F = 230&lt;br /&gt;
&amp;nbsp; C = 120&amp;nbsp;&amp;nbsp; F = 248&lt;br /&gt;
&lt;br /&gt;
*/&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; color: black; font-family: &#39;Times New Roman&#39;; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;b&gt;Example Program No :2&lt;/b&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; color: black; font-family: &#39;Times New Roman&#39;; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; color: black; font-family: &#39;Times New Roman&#39;; font-size: small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;Write a program that writes your name on the monitor 10 times by calling a function to do the writing. Move the called function ahead of the main function to see if your C compiler will allow it.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; color: black; font-family: &#39;Times New Roman&#39;; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; color: black; font-family: &#39;Times New Roman&#39;; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;#include &quot;stdio.h&quot;&lt;br /&gt;
&lt;br /&gt;
void writename();&lt;br /&gt;
&lt;br /&gt;
void writename()&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;&amp;nbsp; printf(&quot;John Q. Doe\n&quot;);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
int index;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; for(index = 0 ; index &amp;lt; 10 ; index = index + 1)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; writename();&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
/* Result of execution&lt;br /&gt;
&lt;br /&gt;
John Q. Doe&lt;br /&gt;
John Q. Doe&lt;br /&gt;
John Q. Doe&lt;br /&gt;
John Q. Doe&lt;br /&gt;
John Q. Doe&lt;br /&gt;
John Q. Doe&lt;br /&gt;
John Q. Doe&lt;br /&gt;
John Q. Doe&lt;br /&gt;
John Q. Doe&lt;br /&gt;
John Q. Doe&lt;br /&gt;
&lt;br /&gt;
*/&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; color: black; font-family: &#39;Times New Roman&#39;; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;b&gt;Example Program No :3&lt;/b&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; color: black; font-family: &#39;Times New Roman&#39;; font-size: small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;Add prototyping to the programs named SUMSQRES.C and SQUARES.C, and change the function definitions to the modern method.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; color: black; font-family: &#39;Times New Roman&#39;; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; color: black; font-family: &#39;Times New Roman&#39;; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
void header(void);&lt;br /&gt;
void square(int number);&lt;br /&gt;
void ending(void);&lt;br /&gt;
&lt;br /&gt;
int sum; /* This is a global variable */&lt;br /&gt;
&lt;br /&gt;
int main(void)&lt;br /&gt;
{&lt;br /&gt;
int index;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; header();&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* This calls the function named header */&lt;br /&gt;
&amp;nbsp;&amp;nbsp; for (index = 1 ; index &amp;lt;= 7 ; index++)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; square(index);&amp;nbsp; /* This calls the square function */&lt;br /&gt;
&amp;nbsp;&amp;nbsp; ending();&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* This calls the ending function */&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void header(void)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* This is the function named header */&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;&amp;nbsp; sum = 0;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Initialize the variable &quot;sum&quot; */&lt;br /&gt;
&amp;nbsp;&amp;nbsp; printf(&quot;This is the header for the square program\n\n&quot;);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void square(int number)&amp;nbsp;&amp;nbsp; /* This is the square function */&lt;br /&gt;
{&lt;br /&gt;
int numsq;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; numsq = number * number;&amp;nbsp; /* This produces the square */&lt;br /&gt;
&amp;nbsp;&amp;nbsp; sum += numsq;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; printf(&quot;The square of %d is %d\n&quot;, number, numsq);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void ending(void)&amp;nbsp;&amp;nbsp; /* This is the ending function */&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;&amp;nbsp; printf(&quot;\nThe sum of the squares is %d\n&quot;, sum);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
/* Result of execution&lt;br /&gt;
&lt;br /&gt;
This is the header for the square program&lt;br /&gt;
&lt;br /&gt;
The square of 1 is 1&lt;br /&gt;
The square of 2 is 4&lt;br /&gt;
The square of 3 is 9&lt;br /&gt;
The square of 4 is 16&lt;br /&gt;
The square of 5 is 25&lt;br /&gt;
The square of 6 is 36&lt;br /&gt;
The square of 7 is 49&lt;br /&gt;
&lt;br /&gt;
The sum of the squares is 140&lt;br /&gt;
&lt;br /&gt;
*/&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; color: black; font-family: &#39;Times New Roman&#39;; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;SCRIPT LANGUAGE=&quot;JavaScript1.1&quot; SRC=&quot;http://bdv.bidvertiser.com/BidVertiser.dbm?pid=356752&amp;bid=1629957&quot; type=&quot;text/javascript&quot;&gt;&lt;/SCRIPT&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/650183537613822215/posts/default/1445444687111180441'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/650183537613822215/posts/default/1445444687111180441'/><link rel='alternate' type='text/html' href='http://c-completereference.blogspot.com/2010/12/programs-in-functions-variables-and.html' title='Programs In FUNCTIONS, VARIABLES, AND PROTOTYPES of C'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-650183537613822215.post-8322876929095199961</id><published>2010-12-18T08:17:00.001-08:00</published><updated>2010-12-18T09:07:05.687-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Programs In ASSIGNMENT AND LOGICAL COMPARES of  C"/><title type='text'>Programs In ASSIGNMENT &amp; LOGICAL COMPARES of  C</title><content type='html'>&lt;b&gt;C Tutorial&amp;nbsp; &lt;/b&gt;&lt;br /&gt;
&lt;b&gt; &lt;/b&gt;&lt;br /&gt;
&amp;nbsp;&lt;b&gt;Programs In &lt;/b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; color: black; font-family: &#39;Times New Roman&#39;; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: small;&quot;&gt;ASSIGNMENT &amp;amp;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;LOGICAL&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;COMPARES of&lt;/span&gt;&amp;nbsp; &lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;b&gt;C&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; color: black; font-family: &#39;Times New Roman&#39;; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;b&gt;Example Program No : 1&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;li&gt;Write a program that will count from 1 to 12 and print the count, and its square, for each count.&lt;/li&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
int index, square;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; for(index = 1 ; index &amp;lt; 13 ; index = index + 1) &lt;br /&gt;
&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; square = index * index;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&quot;%5d%5d\n&quot;, index, square);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
/* Result of execution&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&amp;nbsp;&amp;nbsp;&amp;nbsp; 9&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&amp;nbsp;&amp;nbsp; 16&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&amp;nbsp;&amp;nbsp; 25&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; 6&amp;nbsp;&amp;nbsp; 36&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; 7&amp;nbsp;&amp;nbsp; 49&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; 8&amp;nbsp;&amp;nbsp; 64&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; 9&amp;nbsp;&amp;nbsp; 81&lt;br /&gt;
&amp;nbsp;&amp;nbsp; 10&amp;nbsp; 100&lt;br /&gt;
&amp;nbsp;&amp;nbsp; 11&amp;nbsp; 121&lt;br /&gt;
&amp;nbsp;&amp;nbsp; 12&amp;nbsp; 144&lt;br /&gt;
&lt;br /&gt;
*/&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;b&gt;Example Program No :2&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;li&gt;Write a program that counts from 1 to 12 and prints the count and its inversion to 5 decimal places for each count. This will require a floating point number.&lt;/li&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
int index;&lt;br /&gt;
float inversion;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; for(index = 1 ; index &amp;lt; 13 ; index = index + 1) &lt;br /&gt;
&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; inversion = 1.0/index;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&quot;%5d%9.5f\n&quot;, index, inversion);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
/* Result of execution&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp; 1.00000&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .50000&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .33333&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .25000&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .20000&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; 6&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .16667&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; 7&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .14286&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; 8&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .12500&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; 9&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .11111&lt;br /&gt;
&amp;nbsp;&amp;nbsp; 10&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .10000&lt;br /&gt;
&amp;nbsp;&amp;nbsp; 11&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .09091&lt;br /&gt;
&amp;nbsp;&amp;nbsp; 12&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .08333&lt;br /&gt;
&lt;br /&gt;
*/&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;b&gt;Example Program No :3&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Write a program that will count from 1 to 100 and print only those values between 32 and 39, one to a line. Use the incrementing operator for this program.&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
int index;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; for(index = 1 ; index &amp;lt; 101 ; index = index + 1) &lt;br /&gt;
&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ((index &amp;gt;= 32) &amp;amp;&amp;amp; (index &amp;lt;= 39))&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&quot;%5d\n&quot;, index);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
/* Result of execution&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; 32&lt;br /&gt;
&amp;nbsp;&amp;nbsp; 33&lt;br /&gt;
&amp;nbsp;&amp;nbsp; 34&lt;br /&gt;
&amp;nbsp;&amp;nbsp; 35&lt;br /&gt;
&amp;nbsp;&amp;nbsp; 36&lt;br /&gt;
&amp;nbsp;&amp;nbsp; 37&lt;br /&gt;
&amp;nbsp;&amp;nbsp; 38&lt;br /&gt;
&amp;nbsp;&amp;nbsp; 39&lt;br /&gt;
&lt;br /&gt;
*/&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;SCRIPT LANGUAGE=&quot;JavaScript1.1&quot; SRC=&quot;http://bdv.bidvertiser.com/BidVertiser.dbm?pid=356752&amp;bid=1629957&quot; type=&quot;text/javascript&quot;&gt;&lt;/SCRIPT&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/650183537613822215/posts/default/8322876929095199961'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/650183537613822215/posts/default/8322876929095199961'/><link rel='alternate' type='text/html' href='http://c-completereference.blogspot.com/2010/12/programs-in-assignment-logical-compares.html' title='Programs In ASSIGNMENT &amp; LOGICAL COMPARES of  C'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-650183537613822215.post-6219418384818528787</id><published>2010-12-18T08:13:00.001-08:00</published><updated>2010-12-18T09:06:05.890-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Programs In Controls Of C"/><title type='text'>Programs In Controls Of C</title><content type='html'>&lt;b&gt;C Tutorial&amp;nbsp; &lt;/b&gt;&lt;br /&gt;
&lt;b&gt; &lt;/b&gt;&lt;br /&gt;
&lt;b&gt;Programs In Program Controls &lt;/b&gt;&lt;b&gt;Of C&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Example Program No : 1&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;/b&gt;&lt;br /&gt;
&lt;li style=&quot;font-weight: normal;&quot;&gt;&lt;b&gt;Write a program that writes your name on the monitor ten times.&amp;nbsp;&lt;/b&gt;&lt;/li&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
int index;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; for(index = 0 ; index &amp;lt; 10 ; index = index + 1)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&quot;John Q. Doe\n&quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
/* Result of execution&lt;br /&gt;
&lt;br /&gt;
John Q. Doe&lt;br /&gt;
John Q. Doe&lt;br /&gt;
John Q. Doe&lt;br /&gt;
John Q. Doe&lt;br /&gt;
John Q. Doe&lt;br /&gt;
John Q. Doe&lt;br /&gt;
John Q. Doe&lt;br /&gt;
John Q. Doe&lt;br /&gt;
John Q. Doe&lt;br /&gt;
John Q. Doe&lt;br /&gt;
&lt;br /&gt;
*/&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;b&gt;Example Program No :2&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: normal;&quot;&gt;&lt;b&gt;&lt;/b&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;li style=&quot;font-weight: normal;&quot;&gt;&lt;b&gt;&lt;b&gt;Write this program three times, once with each looping method.&lt;/b&gt;&lt;/b&gt;&lt;/li&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;/b&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
int index;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; index = 0;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; do &lt;br /&gt;
&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&quot;John Q. Doe\n&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; index = index + 1;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; } while (index &amp;lt; 10);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
/* Result of execution&lt;br /&gt;
&lt;br /&gt;
John Q. Doe&lt;br /&gt;
John Q. Doe&lt;br /&gt;
John Q. Doe&lt;br /&gt;
John Q. Doe&lt;br /&gt;
John Q. Doe&lt;br /&gt;
John Q. Doe&lt;br /&gt;
John Q. Doe&lt;br /&gt;
John Q. Doe&lt;br /&gt;
John Q. Doe&lt;br /&gt;
John Q. Doe&lt;br /&gt;
&lt;br /&gt;
*/&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Example Program No :3&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;/b&gt;&lt;br /&gt;
&lt;div style=&quot;font-weight: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;/div&gt;&lt;li style=&quot;font-weight: normal;&quot;&gt;&lt;b&gt;Write a program that counts from one to ten, prints the values on a separate line for each, and includes a message of your choice when the count is 3 and a different message when the count is 7.&lt;/b&gt;&lt;/li&gt;&lt;br /&gt;
&lt;div style=&quot;font-weight: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;font-weight: normal;&quot;&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
int index;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; index = 1;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; do &lt;br /&gt;
&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&quot;The count is now %2d&quot;,index);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (index == 3)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&quot; and is equal to three.&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (index == 7)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&quot; and is equal to seven.&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&quot;\n&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; index = index + 1;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; } while (index &amp;lt; 11);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
/* Result of execution&lt;br /&gt;
&lt;br /&gt;
The count is now&amp;nbsp; 1&lt;br /&gt;
The count is now&amp;nbsp; 2&lt;br /&gt;
The count is now&amp;nbsp; 3 and is equal to three.&lt;br /&gt;
The count is now&amp;nbsp; 4&lt;br /&gt;
The count is now&amp;nbsp; 5&lt;br /&gt;
The count is now&amp;nbsp; 6&lt;br /&gt;
The count is now&amp;nbsp; 7 and is equal to seven.&lt;br /&gt;
The count is now&amp;nbsp; 8&lt;br /&gt;
The count is now&amp;nbsp; 9&lt;br /&gt;
The count is now&amp;nbsp; 10&lt;br /&gt;
&lt;br /&gt;
*/&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;SCRIPT LANGUAGE=&quot;JavaScript1.1&quot; SRC=&quot;http://bdv.bidvertiser.com/BidVertiser.dbm?pid=356752&amp;bid=1629957&quot; type=&quot;text/javascript&quot;&gt;&lt;/SCRIPT&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/650183537613822215/posts/default/6219418384818528787'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/650183537613822215/posts/default/6219418384818528787'/><link rel='alternate' type='text/html' href='http://c-completereference.blogspot.com/2010/12/programs-in-controls-of-c.html' title='Programs In Controls Of C'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-650183537613822215.post-2029334395848619559</id><published>2010-12-18T08:08:00.001-08:00</published><updated>2010-12-18T23:08:04.135-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Basic Programs In C"/><title type='text'>Basic Programs In C</title><content type='html'>&lt;b&gt;C Tutorial&amp;nbsp; &lt;/b&gt;&lt;b&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;Basic Programs In C&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Example Program No : 1&lt;/b&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; color: black; font-family: &#39;Times New Roman&#39;; font-size: small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;&lt;br /&gt;
&lt;li&gt;Write a program to display your name on the monitor.&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;/li&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;&amp;nbsp; printf(&quot;John Q. Doe\n&quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
/* Result of execution&lt;br /&gt;
&lt;br /&gt;
John Q. Doe&lt;br /&gt;
&lt;br /&gt;
*/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Example Program No : 2&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; color: black; font-family: &#39;Times New Roman&#39;; font-size: small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;&lt;br /&gt;
&lt;li&gt;Modify the program to display your address and phone number on separate lines by adding two additional&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;b&gt;printf()&lt;/b&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;statements.&lt;/li&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;&amp;nbsp; printf(&quot;John Q. Doe\n&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; printf(&quot;1234 Main Street\n&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; printf(&quot;(505) 555-1212\n&quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
/* Result of execution&lt;br /&gt;
&lt;br /&gt;
John Q. Doe&lt;br /&gt;
1234 Main Street&lt;br /&gt;
(505) 555-1212&lt;br /&gt;
&lt;br /&gt;
*/&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Example Program No :3&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; color: black; font-family: &#39;Times New Roman&#39;; font-size: small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;&lt;br /&gt;
&lt;li&gt;Remove  line 7 from ONEINT.C by commenting it out, then compile and execute the  resulting program to see the value of an uninitialized variable. This  can be any value within the allowable range for that variable. If it  happens to have the value of zero, that is only a coincidence, but then  zero is the most probable value to be in an uninitialized variable  because there are lots of zero values floating around in a computer&#39;s  memory. It is actually legal for the program to abort if you refer to a  variable that you failed to initialize, but few compilers, if any, will  actually do so.&lt;b&gt;&amp;nbsp; &lt;/b&gt;&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;/li&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
int index;&lt;br /&gt;
&lt;br /&gt;
/* index = 13; */&lt;br /&gt;
&amp;nbsp;&amp;nbsp; printf(&quot;The value of the index is %d\n&quot;, index);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; index = 27;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; printf(&quot;The value of the index is %d\n&quot;, index);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; index = 10;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; printf(&quot;The value of the index is %d\n&quot;, index);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Example Program No : 4&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; color: black; font-family: &#39;Times New Roman&#39;; font-size: small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;li&gt;Add the following two lines just after the last&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;b&gt;printf()&lt;/b&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;of ONEINT.C to see what it does. Study it long enough to completely understand the result.&lt;/li&gt;&lt;br /&gt;
&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;pre&gt;printf(&quot;Index is %d\n it still is %d\n it is %d&quot;,&lt;/pre&gt;&lt;br /&gt;
&lt;pre&gt;index, index, index);&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;................... &lt;/pre&gt;&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
int index;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; index = 13;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; printf(&quot;The value of the index is %d\n&quot;, index);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; index = 27;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; printf(&quot;The value of the index is %d\n&quot;, index);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; index = 10;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; printf(&quot;The value of the index is %d\n&quot;, index);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp; printf(&quot;Index is %d\n it still is %d\n it is %d&quot;,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; index, index, index);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp; return 0;&lt;br /&gt;
}&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;SCRIPT LANGUAGE=&quot;JavaScript1.1&quot; SRC=&quot;http://bdv.bidvertiser.com/BidVertiser.dbm?pid=356752&amp;bid=1629957&quot; type=&quot;text/javascript&quot;&gt;&lt;/SCRIPT&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/650183537613822215/posts/default/2029334395848619559'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/650183537613822215/posts/default/2029334395848619559'/><link rel='alternate' type='text/html' href='http://c-completereference.blogspot.com/2010/12/basic-programs-in-c.html' title='Basic Programs In C'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-650183537613822215.post-3987892312117184145</id><published>2010-12-18T07:07:00.001-08:00</published><updated>2010-12-18T07:07:18.129-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="STRINGS.C"/><title type='text'>STRINGS.C</title><content type='html'>&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Chapter 7 - Program 2 - STRINGS.C */&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;string.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
char name1[12], name2[12], mixed[25];&lt;br /&gt;
char title[20];&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; strcpy(name1, &quot;Rosalinda&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; strcpy(name2, &quot;Zeke&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; strcpy(title, &quot;This is the title.&quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; printf(&quot;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %s\n\n&quot;, title);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; printf(&quot;Name 1 is %s\n&quot;, name1);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; printf(&quot;Name 2 is %s\n&quot;, name2);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; if(strcmp(name1, name2) &amp;gt; 0)&amp;nbsp; /* returns 1 if name1 &amp;gt; name2 */&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; strcpy(mixed, name1);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; else&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; strcpy(mixed, name2);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; printf(&quot;The biggest name alphabetically is %s\n&quot;, mixed);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; strcpy(mixed, name1);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; strcat(mixed, &quot;&amp;nbsp; &quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; strcat(mixed, name2);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; printf(&quot;Both names are %s\n&quot;, mixed);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
/* Result of execution&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; This is the title.&lt;br /&gt;
&lt;br /&gt;
Name1 is Rosalinda&lt;br /&gt;
Name2 is Zeke&lt;br /&gt;
The biggest name alphabetically is Zeke&lt;br /&gt;
Both names are Rosalinda&amp;nbsp; Zeke&lt;br /&gt;
&lt;br /&gt;
*/&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;SCRIPT LANGUAGE=&quot;JavaScript1.1&quot; SRC=&quot;http://bdv.bidvertiser.com/BidVertiser.dbm?pid=356752&amp;bid=1629957&quot; type=&quot;text/javascript&quot;&gt;&lt;/SCRIPT&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/650183537613822215/posts/default/3987892312117184145'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/650183537613822215/posts/default/3987892312117184145'/><link rel='alternate' type='text/html' href='http://c-completereference.blogspot.com/2010/12/stringsc.html' title='STRINGS.C'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-650183537613822215.post-8328460535166113574</id><published>2010-12-18T06:17:00.003-08:00</published><updated>2010-12-18T06:17:50.982-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="OPERATORS"/><title type='text'>OPERATORS</title><content type='html'>&lt;P&gt;&lt;CENTER&gt;&lt;B&gt;&lt;FONT SIZE=4 FACE=&quot;Arial&quot;&gt;OPERATORS&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;/B&gt;&lt;/CENTER&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;Operators are tokens that cause a computation&lt;br /&gt;
to occur when applied to variables. C provides the following operators;&lt;br /&gt;
&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;&amp;amp; Address &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;* Indirection &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;+ Unary plus &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;- Unary minus &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;~ Bitwise compliment &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;! Logical negation &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;++ As a prefix; preincrement &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; As a suffix; postincrement &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;-- As a prefix; predecrement &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; As a suffix; postdecrement &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;+ Addition &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;- Subtraction &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;* Multiply &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;/ Divide &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;% Remainder &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;&amp;lt;&amp;lt; Shift left &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;&amp;gt;&amp;gt; Shift right &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;&amp;amp; Bitwise AND &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;| Bitwise OR &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;^ Bitwise XOR &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;&amp;amp;&amp;amp; Logical AND &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;|| Logical OR &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;= Assignment &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;*= Assign product &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;/= Assign quotient &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;%= Assign remainder (modulus) &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;+= Assign sum &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;-= Assign difference &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;&amp;lt;&amp;lt;= Assign left shift &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;&amp;gt;&amp;gt;= Assign right shift &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;&amp;amp;= Assign bitwise AND &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;|= Assign bitwise OR &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;^= Assign bitwise XOR &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;&amp;lt; Less than &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;&amp;gt; Greater than &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;&amp;lt;= Less than or equal to &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;&amp;gt;= Greater than or equal to &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;== Equal to &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;!= Not equal to &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;. Direct component selector &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;-&amp;gt; Indirect component selector &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;a ? x:y &amp;quot;If a is true then x else&lt;br /&gt;
y&amp;quot; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;[] Define arrays &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;() Parenthesis isolate conditions and&lt;br /&gt;
expressions &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;... Ellipsis are used in formal parameter&lt;br /&gt;
lists of  &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; function prototypes to show a variable&lt;br /&gt;
number of &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; parameters or parameters of varying&lt;br /&gt;
types. &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;To illustrate some more commonly used&lt;br /&gt;
operators consider the following short program; &lt;BR&gt;&lt;br /&gt;
&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;main()&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;{&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int a;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int b;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int c;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; a = 5;    /* Assign a value of 5 to&lt;br /&gt;
variable &#39;a&#39; */&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; b = a / 2;   /* Assign the value of&lt;br /&gt;
&#39;a&#39; divided by two to      variable &#39;b&#39; */&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; c = b * 2;   /* Assign the value of&lt;br /&gt;
&#39;b&#39; multiplied by two      to variable &#39;c&#39; */&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; if (a == c)  /* Test if &#39;a&#39; holds the&lt;br /&gt;
same value as &#39;c&#39; */&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  puts(&amp;quot;Variable &#39;a&#39; is an even&lt;br /&gt;
number&amp;quot;);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; else&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  puts(&amp;quot;Variable &#39;a&#39; is an odd&lt;br /&gt;
number&amp;quot;);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;}&lt;BR&gt;&lt;br /&gt;
&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;Normally when incrementing the value&lt;br /&gt;
of a variable you would write something like; &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  x = x + 1&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;C provides the incremental operator&lt;br /&gt;
&#39;++&#39; as well so that you can write;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  x++&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;Similarly you can decrement the value&lt;br /&gt;
of a variable using &#39;--&#39; as;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  x--&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;All the other mathematical operators&lt;br /&gt;
may be used the same, so in a C program you can write in shorthand;&lt;br /&gt;
&lt;BR&gt;&lt;br /&gt;
&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;NORMAL C &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;x = x + 1 x++ &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;x = x - 1 x-- &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;x = x * 2 x *= 2 &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;x = x / y x /= y &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;x = x % 5 x %= 5 &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;and so on.&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;SCRIPT LANGUAGE=&quot;JavaScript1.1&quot; SRC=&quot;http://bdv.bidvertiser.com/BidVertiser.dbm?pid=356752&amp;bid=1629957&quot; type=&quot;text/javascript&quot;&gt;&lt;/SCRIPT&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/650183537613822215/posts/default/8328460535166113574'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/650183537613822215/posts/default/8328460535166113574'/><link rel='alternate' type='text/html' href='http://c-completereference.blogspot.com/2010/12/operators.html' title='OPERATORS'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-650183537613822215.post-8806436061615081794</id><published>2010-12-18T06:17:00.001-08:00</published><updated>2010-12-18T06:17:12.870-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="PC GRAPHICS"/><title type='text'>PC GRAPHICS</title><content type='html'>&lt;P&gt;&lt;CENTER&gt;&lt;B&gt;&lt;FONT SIZE=4 FACE=&quot;Arial&quot;&gt;PC GRAPHICS&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;/B&gt;&lt;/CENTER&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;When programming graphics you should&lt;br /&gt;
bear in mind that they are a machine dependant subject. Code to&lt;br /&gt;
produce graphics on an IBM PC will not port to an Amiga, or VAX&lt;br /&gt;
or any other type of computer. &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;I&gt;&lt;B&gt;&lt;FONT FACE=&quot;Arial&quot;&gt;Introduction To PC Graphics&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;/B&gt;&lt;/I&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;The IBM PC and compatible range of computers&lt;br /&gt;
display information on a visual display unit (VDU). To enable&lt;br /&gt;
the computer to send information to the VDU a component is included&lt;br /&gt;
within the computer called a &amp;quot;display card&amp;quot;. There are&lt;br /&gt;
various display cards and VDUs which have been produced for the&lt;br /&gt;
IBM PC range of computers; monochrome display adapter (MDA), colour&lt;br /&gt;
graphics adapter (CGA), Hercules graphics card (HGC), Enhanced&lt;br /&gt;
graphics adapter (EGA), video graphics array (VGA), super video&lt;br /&gt;
graphics array (SVGA), memory controller gate array (MCGA), 8514/A&lt;br /&gt;
and the Txas Instruments Graphics Architecture (TIGA). For simplicity,&lt;br /&gt;
this section will concern itself only with the three more common&lt;br /&gt;
types of display; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; CGA, EGA and VGA&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;Information about the VGA display is&lt;br /&gt;
also relevant to the SVGA display which in simple terms can do&lt;br /&gt;
the same and more. This section will not concern itself with monochrome&lt;br /&gt;
displays since they are of limited use in graphics work. &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;I&gt;&lt;B&gt;&lt;FONT FACE=&quot;Arial&quot;&gt;Display Modes&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;/B&gt;&lt;/I&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;When an IBM PC computer is first switched&lt;br /&gt;
on is set to display 80 columns by 25 rows of writing. This measurement,&lt;br /&gt;
80 x 25 is called the &amp;quot;resolution&amp;quot;. A display mode which&lt;br /&gt;
is intended for displaying writing is called a &amp;quot;text&amp;quot;&lt;br /&gt;
mode.  Where as a display mode which is intended for displaying&lt;br /&gt;
pictures is called a &amp;quot;graphics&amp;quot; mode. &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;If you look closely at the display you&lt;br /&gt;
will see that each displayed character is comprised of dots. In&lt;br /&gt;
reality the entire display is comprised of dots, called &amp;quot;pixels&amp;quot;,&lt;br /&gt;
which may be set to different colours. In text display modes these&lt;br /&gt;
pixels are not very relevant, however, in graphics display modes&lt;br /&gt;
each pixel may be selected and set by a program. The size of the&lt;br /&gt;
pixels varies with the display resolution. In 80 x 25 text mode&lt;br /&gt;
the pixels are half the width they are in 40 x 25 text display&lt;br /&gt;
mode.&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;Depending upon the display card installed&lt;br /&gt;
in the computer, there are a number of display modes which may&lt;br /&gt;
be used;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;MODE TYPE RESOLUTION COLOURS &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;    &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; 0   Text 40 x 25 4 (CGA), 16 (EGA,&lt;br /&gt;
VGA) Shades of grey  &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; 1   Text 40 x 25 4 (CGA), 16 (EGA,&lt;br /&gt;
VGA) &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; 2   Text 80 x 25 4 (CGA), 16 (EGA,&lt;br /&gt;
VGA) Shades of grey  &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; 3   Text 80 x 25 4 (CGA), 16 (EGA,&lt;br /&gt;
VGA) &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; 4   Graphics 320 x 200 4 &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; 5   Graphics 320 x 200 4 (grey on CGA&lt;br /&gt;
and EGA) &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; 6   Graphics 640 x 200 2 &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; 7   Text 80 x 25 Mono (EGA, VGA) &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;13   Graphics 320 x 200 16 (EGA, VGA)&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;14   Graphics 640 x 200 16 (EGA, VGA)&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;15   Graphics  640 x 350 Mono (EGA,&lt;br /&gt;
VGA) &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;16   Graphics  640 x 350 16 (EGA, VGA)&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;17   Graphics 640 x 480 2 (VGA) &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;18   Graphics 640 x 480 16 (VGA) &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;19   Graphics 320 x 200 256 (VGA) &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;The term resolution in graphics modes&lt;br /&gt;
refers to the number of pixels across and down the VDU. The larger&lt;br /&gt;
the number of pixels, the smaller each is and the sharper any&lt;br /&gt;
displayed image appears. As you can see from the table, the VGA&lt;br /&gt;
display can produce a higher resolution than the other display&lt;br /&gt;
cards, resulting in sharper images being produced. &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;The CGA display card can produce a maximum&lt;br /&gt;
resolution of 320 x 200 pixels, where as the VGA display card&lt;br /&gt;
can produce a resolution of 640 x 480 pixels.  This is why writing&lt;br /&gt;
on a VGA VDU looks so much sharper than the writing displayed&lt;br /&gt;
on a CGA VDU. &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;I&gt;&lt;B&gt;&lt;FONT FACE=&quot;Arial&quot;&gt;Accessing The Display&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;/B&gt;&lt;/I&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;Inside the IBM PC computer is a silicon&lt;br /&gt;
chip called the BIOS ROM, this chip contains functions which may&lt;br /&gt;
be called by an external computer program to access the display&lt;br /&gt;
card, which in turn passes the information on to the VDU.  The&lt;br /&gt;
BIOS display functions are all accessed by generating interrupt&lt;br /&gt;
10 calls, with the number of the appropriate function stored in&lt;br /&gt;
the assembly language AH register. &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;A programmer interested in creating&lt;br /&gt;
graphics displays must first be able to switch the display card&lt;br /&gt;
to an appropriate graphics mode. This is achieved by calling the&lt;br /&gt;
BIOS display function 0, with th number of the desired display&lt;br /&gt;
mode from the table stored in the assembly language AL register&lt;br /&gt;
thus the following assembly language code segment will switch&lt;br /&gt;
the display card to CGA graphics mode 4, assuming that is that&lt;br /&gt;
the display card is capable of this mode; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  mov  ah , 00&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  mov  al , 04&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  int  10h&lt;BR&gt;&lt;br /&gt;
&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;A C function for selecting video display&lt;br /&gt;
modes can be written;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;#include &amp;lt;dos.h&amp;gt;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;void setmode(unsigned char mode)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;{&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Sets the video display mode */&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; union REGS inregs outreg;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; inreg.h.ah = 0;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; inreg.h.al = mode;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int86(0x10,&amp;amp;inreg,&amp;amp;outregs);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;}&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;Any graphics are created by setting&lt;br /&gt;
different pixels to different colours, this is termed &amp;quot;plotting&amp;quot;,&lt;br /&gt;
and is achieved by calling BIOS display function 12 with the pixel&#39;s&lt;br /&gt;
horizontal coordinate in the assembly language CX register and&lt;br /&gt;
it&#39;s vertical coordinate in the assembly language DX register&lt;br /&gt;
and the required colour in the assembly language AL register thus;&lt;br /&gt;
&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  mov  ah, 12&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  mov  al, colour&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  mov  bh, 0&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  mov  cx, x_coord&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  mov  dx, y_coord&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  int  10h&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;The corresponding C function is;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;#include &amp;lt;dos.h&amp;gt;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;void plot(int x_coord, int y_coord,&lt;br /&gt;
unsigned char colour)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;{&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Sets the colour of a pixel */&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; union REGS regs;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; regs.h.ah = 12;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; regs.h.al = colour;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; regs.h.bh = 0;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; regs.x.cx = x_coord;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; regs.x.dx = y_coord;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int86(0x10,&amp;amp;regs,&amp;amp;regs);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;}&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;The inverse function of plot is to read&lt;br /&gt;
the existing colour setting of a pixel. This is done by calling&lt;br /&gt;
BIOS ROM display function 13, again with the pixel&#39;s horizontal&lt;br /&gt;
coordinate in the assembly language CX register and it&#39;s vertical&lt;br /&gt;
coordinate in the assembly language DX register. This function&lt;br /&gt;
then returns the pixel&#39;s colour in the assembly language AL register;&lt;br /&gt;
&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;#include &amp;lt;dos.h&amp;gt;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;unsigned char get_pixel(int x_coord,&lt;br /&gt;
int y_coord)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;{&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Reads the colour of a pixel */&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; union REGS inreg, outreg;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; inreg.h.ah = 13;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; inreg.h.bh = 0;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; inreg.x.cx = x_coord;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; inreg.x.dx = y_coord;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int86(0x10,&amp;amp;inreg,&amp;amp;outreg);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; return(outreg.h.al);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;}&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;I&gt;&lt;B&gt;&lt;FONT FACE=&quot;Arial&quot;&gt;Colour And The CGA&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;/B&gt;&lt;/I&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;The CGA display card can display a maximum&lt;br /&gt;
of 4 colours simultaneously at any time. However, the display&lt;br /&gt;
card can generate a total of 8 colours. There are two sets of&lt;br /&gt;
colours, called &amp;quot;palettes&amp;quot;. The first palette contains&lt;br /&gt;
the colours; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; background, cyan, magenta and white.&lt;br /&gt;
&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;the second palette contains the colours;&lt;br /&gt;
&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   background, green, red and yellow.&lt;br /&gt;
&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;Colour 0 is always the same as the background&lt;br /&gt;
colour.&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;The pixels displayed on the VDU take&lt;br /&gt;
their colours from the currently active palette, and are continuously&lt;br /&gt;
being refreshed. So, if the active palette changes, so to do the&lt;br /&gt;
colours of the displayed pixels on the VDU.&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;Selection of the active CGA palette&lt;br /&gt;
is achieved by calling the BIOS display function 11 with the number&lt;br /&gt;
of the desired palette (either 0 or 1) in the assembly language&lt;br /&gt;
BH register;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  mov  ah, 11&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  mov  bh, palette&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  int  10h&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;The C function for selecting the CGA&lt;br /&gt;
palette is;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;void palette(unsigned char palette)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;{&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; union REGS inreg, outreg;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; inreg.h.ah = 11;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; inreg.h.bh = palette;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int86(0x10,&amp;amp;inreg,&amp;amp;outreg);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;}&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;The background colour may be selected&lt;br /&gt;
independantly from any of the eight available colours by calling&lt;br /&gt;
the same BIOS display function with a value of 0 stored in the&lt;br /&gt;
assembly language BH register and the desired background colour&lt;br /&gt;
in the assembly language BL register; &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; mov  ah, 11&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; mov  bh, 0&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; mov  bl, colour&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int  10h&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;In C this function can be written;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;void background(unsigned char colour)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;{&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; union REGS inreg, outreg;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; inreg.h.ah = 11;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; inreg.h.bh = 0;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; inreg.h.bl = colour;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int86(0x10,&amp;amp;inreg,&amp;amp;outreg);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;}&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;The background colours available are;&lt;br /&gt;
&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; 0    Black&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; 1    Blue&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; 2    Green&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; 3    Cyan&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; 4    Red&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; 5    Magenta&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; 6    Yellow&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; 7    White&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;I&gt;&lt;B&gt;&lt;FONT FACE=&quot;Arial&quot;&gt;Colour And The EGA&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;/B&gt;&lt;/I&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;The EGA display card can display a maximum&lt;br /&gt;
of 16 colours simultaneously at any time. The colour of all pixels&lt;br /&gt;
is continuously refreshed by the display card by reading the colour&lt;br /&gt;
from the EGA palette. Unlike the CGA display card, the EGA display&lt;br /&gt;
card allows you to redefine any or all of the colours in the palette.&lt;br /&gt;
Unfortunately only the first 8 colours may be loaded into other&lt;br /&gt;
palette colours. &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;The colours are;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; 0    Black&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; 1    Blue&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; 2    Green&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; 3    Cyan&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; 4    Red&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; 5    Magenta&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; 6    Brown&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; 7    Light grey&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; 8    Dark grey&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; 9    Light blue&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;    10    Light green&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;    11  Light cyan&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;    12    Light red&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;    13    Light magenta&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;    14    Yellow&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;    15    White&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;Changing a palette colour is achieved&lt;br /&gt;
by calling the BIOS display function 16 with a value of 0 in the&lt;br /&gt;
assembly language AL register, the colour value (0 to 7) in the&lt;br /&gt;
assembly language BH register and the number of the palette colour&lt;br /&gt;
(0 to 15) in the assembly language BL register thus; &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; mov  ah,16&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; mov  al,0&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; mov  bl,palette&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; mov  bh,colour&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int  10h&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;In C this function may be written;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;void ega_palette(unsigned char colour,&lt;br /&gt;
unsigned char palette)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;{&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; union REGS inreg,outreg;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; inreg.h.ah = 16;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; inreg.h.al = 0;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; inreg.h.bl = palette;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; inreg.h.bh = colour;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int86(0x10,&amp;amp;inreg,&amp;amp;outreg);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;}&lt;BR&gt;&lt;br /&gt;
&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;I&gt;&lt;B&gt;&lt;FONT FACE=&quot;Arial&quot;&gt;Colour And The VGA&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;/B&gt;&lt;/I&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;The VGA display card can display a maximum&lt;br /&gt;
of 256 colours on the VDU at any one time, these colours are defined&lt;br /&gt;
by information held in 256 special registers called &amp;quot;DAC&amp;quot;&lt;br /&gt;
registers. As with the CGA and EGA displays, the colour of displayed&lt;br /&gt;
pixels is continuously being refreshed, and as such any change&lt;br /&gt;
to a DAC register is immediately visible. Each DAC register has&lt;br /&gt;
three component data parts which record the amount of green, blue&lt;br /&gt;
and red colours which make up the displayed colour. Each of these&lt;br /&gt;
seperate data components can hold a value between 0 and 63 giving&lt;br /&gt;
the VGA display card the ability to display 262,144 colours! Although&lt;br /&gt;
only a small subset of them can be displayed at any one time.&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;Setting the value of a DAC register&lt;br /&gt;
is achieved by calling the BIOS display function 16 with a value&lt;br /&gt;
of 16 stored in the assembly language AL register, the green value&lt;br /&gt;
stored in the assembly language CH register, the blue value stored&lt;br /&gt;
in the assembly language CL register and the red value stored&lt;br /&gt;
in the assembly language DH register and the number of the DAC&lt;br /&gt;
register to be set stored in the assembly language BX register;&lt;br /&gt;
&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  mov  ah,16&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  mov  al,16&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  mov  ch,green&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  mov  cl,blue&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  mov  dh,red&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  mov  bx,dac&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  int  10h&lt;BR&gt;&lt;br /&gt;
&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;The C function to set a DAC register&lt;br /&gt;
looks lik this;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;void set_dac(int dac, unsigned char&lt;br /&gt;
green, unsigned char blue, unsigned char red)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;{&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; union REGS regs;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; regs.h.ah = 16;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; regs.h.al = 16;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; regs.x.bx = dac;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; regs.h.ch = green;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; regs.h.cl = blue;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; regs.h.dh = red;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int86(0x10,&amp;amp;regs,&amp;amp;regs);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;}&lt;BR&gt;&lt;br /&gt;
&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;I&gt;&lt;B&gt;&lt;FONT FACE=&quot;Arial&quot;&gt;Displaying Text&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;/B&gt;&lt;/I&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;The BIOS ROM provides three functions&lt;br /&gt;
for displaying a single character. The first function to consider&lt;br /&gt;
is the one used extensively by DOS for displaying messages, this&lt;br /&gt;
is function 14 called &amp;quot;write text in teletype mode&amp;quot;.&lt;br /&gt;
This function interprets some control characters; bell (ascii&lt;br /&gt;
7), backspace (ascii 8), carriage return (ascii 10) and line feed&lt;br /&gt;
(ascii 13) but all other ascii codes are displayed, and the current&lt;br /&gt;
cursor position updated accordingly, moving down a row when a&lt;br /&gt;
character is displayed in the far right column. To call this function&lt;br /&gt;
the assembly language register AL holds the ascii code of the&lt;br /&gt;
character to be displayed and assembly language register BL holds&lt;br /&gt;
the foreground colour for the character to be displayed in if&lt;br /&gt;
a graphics mode is active; &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  mov  ah,14&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  mov  al,character&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  mov  bh,0&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  mov  bl,foreground&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  int  10h&lt;BR&gt;&lt;br /&gt;
&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;A C function for accessing the write&lt;br /&gt;
text in teletype mode may be written like this; &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;#include &amp;lt;dos.h&amp;gt;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;void teletype(unsigned char character,&lt;br /&gt;
unsigned char foreground)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;{&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; union REGS inreg, outreg;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; inreg.h.ah = 14;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; inreg.h.al = character;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; inreg.h.bh = 0;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; inreg.h.bl = foreground;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int86(0x10,&amp;amp;inrg,&amp;amp;outreg);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;}&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;The second BIOS ROM display function&lt;br /&gt;
for displaying a character allows the foreground and background&lt;br /&gt;
colours of the displayed character to be defined. It also allows&lt;br /&gt;
multiple copies of the character to be displayed one after another&lt;br /&gt;
automatically displaying subsequent characters at the next display&lt;br /&gt;
position, although the current cursor position is not changed&lt;br /&gt;
by this function. &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;This function is called &amp;quot;write&lt;br /&gt;
character and attribute&amp;quot;, and is BIOS ROM display function&lt;br /&gt;
number 9. It is called with the ascii code of the character to&lt;br /&gt;
be displayed in the assembly language AL register, the display&lt;br /&gt;
page in assembly language register BH, the foreground colour in&lt;br /&gt;
the first four bits of the assembly language register BL and the&lt;br /&gt;
background colour in the last four bits of the assembly language&lt;br /&gt;
register BL, the number of times the character is to be displayed&lt;br /&gt;
is stored in the assembly language CX register thus; &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  mov  ah,9&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  mov  al,character&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  mov  bh,0&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  mov  bl,foreground + 16 * background&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  mov  cx,number&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  int  10h&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;And in C;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;#include &amp;lt;dos.h&amp;gt;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;void char_attrib(unsigned char character,&lt;br /&gt;
unsigned char foreground, unsigned char background, int number)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;{&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; union REGS inreg,outreg;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; inreg.h.ah = 9;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; inreg.h.al = character;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; inreg.h.bh = 0;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; inreg.h.bl = (background &amp;lt;&amp;lt; 4)&lt;br /&gt;
+ foreground;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; inreg.x.cx = number;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int86(0x10,&amp;amp;inreg,&amp;amp;outreg);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;}&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;The last BIOS ROM display function for&lt;br /&gt;
displaying a character retains the foreground and background colours&lt;br /&gt;
of the display position. &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;This function is called &amp;quot;write&lt;br /&gt;
character&amp;quot;, and is BIOS ROM display function number 10. It&lt;br /&gt;
is identical to BIOS ROM display function 9 except that the colours&lt;br /&gt;
of the displayed character are those which are prevalent at the&lt;br /&gt;
display position, except in graphics modes when the foreground&lt;br /&gt;
colour of the character is determined by the value in the assembly&lt;br /&gt;
language BL register.  Its use is as follows; &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  mov  ah,10&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  mov  al,character&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  mov  bh,0&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  mov  bl,foreground   ; For graphics&lt;br /&gt;
modes ONLY&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  mov  cx,number&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  int  10h&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;And in C;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;#include &amp;lt;dos.h&amp;gt;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;void char_attrib(unsigned char character,&lt;br /&gt;
unsigned char foreground, int number)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;{&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; union REGS inreg,outreg;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; inreg.h.ah = 10;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; inreg.h.al = character;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; inreg.h.bh = 0;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; inreg.h.bl = foreground; /* For graphics&lt;br /&gt;
modes ONLY */&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; inreg.x.cx = number;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int86(0x10,&amp;amp;inreg,&amp;amp;outreg);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;}&lt;BR&gt;&lt;br /&gt;
&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;Positioning of the text cursor is provided&lt;br /&gt;
for by the ROM BIOS display function number 2. It is called with&lt;br /&gt;
the row number in the assembly language register DH and the column&lt;br /&gt;
number in the assembly language register DL; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  mov  ah,2&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  mov  bh,0&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  mov  dh,row&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  mov  dl,column&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  int  10h&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;The corresponding function in C looks&lt;br /&gt;
like this;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;#include &amp;lt;dos.h&amp;gt;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;void at(unsigned char row, unsigned&lt;br /&gt;
char column)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;{&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; union REGS regs;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; regs.h.ah = 2;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; regs.h.bh = 0;    &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; regs.h.dh = row;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; regs.h.dl = column;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int86(0x10,&amp;amp;regs,&amp;amp;regs);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;}&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;From these basic functions a more useful&lt;br /&gt;
replacement for the C language&#39;s &amp;quot;printf()&amp;quot; function&lt;br /&gt;
can be written which allows data to be displayed at the current&lt;br /&gt;
cursor position, previously set by a call to &amp;quot;at()&amp;quot;,&lt;br /&gt;
with prescribed attributes; &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;#include &amp;lt;dos.h&amp;gt;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;#include &amp;lt;stdarg.h&amp;gt;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;void at(unsigned char row, unsigned&lt;br /&gt;
char column)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;{&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; union REGS regs;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; regs.h.ah = 2;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; regs.h.bh = 0;    &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; regs.h.dh = row;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; regs.h.dl = column;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int86(0x10,&amp;amp;regs,&amp;amp;regs);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;}&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;void xprintf(unsigned char foreground,&lt;br /&gt;
unsigned char background, char *format,...)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;{&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; union REGS inreg,outreg;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; va_list arg_ptr;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; static char output[1000];&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; unsigned char col;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; unsigned char row;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; unsigned char n;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; unsigned char p;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; unsigned char text;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; unsigned char attr;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Convert foreground and background&lt;br /&gt;
colours into a single attribute */&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; attr = (background &amp;lt;&amp;lt; 4) + foreground;&lt;br /&gt;
&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Copy data into a single string */&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; va_start(arg_ptr, format);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; vsprintf(output, format, arg_ptr);&lt;br /&gt;
&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Determine number of display columns&lt;br /&gt;
*/&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; inreg.h.ah = 15;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int86(0x10,&amp;amp;inreg,&amp;amp;outreg);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; n = outreg.h.ah;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Determine current cursor position&lt;br /&gt;
*/&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; inreg.h.ah = 3;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; inreg.h.bh = 0;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int86(0x10,&amp;amp;inreg,&amp;amp;outreg);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; row = outreg.h.dh;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; col = outreg.h.dl;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Now display data */&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; p = 0;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; while (output[p])&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; {&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  /* Display this character */&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  inreg.h.bh = 0;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  inreg.h.bl = attr;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  inreg.x.cx = 01;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  inreg.h.ah = 9;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  inreg.h.al = output[p++];&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  int86(0x10,&amp;amp;inreg,&amp;amp;outreg);&lt;br /&gt;
&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  /* Update cursor position */&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  /* moving down a row if required */&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  col++;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  if (col &amp;lt; (n - 1))&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   at(row, col);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  else&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  {&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   col = 0;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   at(++row, col);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  }&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; }&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;}&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;This function, &amp;quot;xprintf()&amp;quot;&lt;br /&gt;
illustrates two more functions of the BIOS ROM. The first is the&lt;br /&gt;
call to function 15 which returns the number of text display columns&lt;br /&gt;
for the currently active display mode. &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;The other function illustrated, but&lt;br /&gt;
not yet discussed, is BIOS ROM function 3 which returns information&lt;br /&gt;
about the cursor. The cursor&#39;s row is returned in the assembly&lt;br /&gt;
language register DH, and it&#39;s column in the assembly language&lt;br /&gt;
register DL. &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;SCRIPT LANGUAGE=&quot;JavaScript1.1&quot; SRC=&quot;http://bdv.bidvertiser.com/BidVertiser.dbm?pid=356752&amp;bid=1629957&quot; type=&quot;text/javascript&quot;&gt;&lt;/SCRIPT&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/650183537613822215/posts/default/8806436061615081794'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/650183537613822215/posts/default/8806436061615081794'/><link rel='alternate' type='text/html' href='http://c-completereference.blogspot.com/2010/12/pc-graphics.html' title='PC GRAPHICS'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-650183537613822215.post-1385411749029472381</id><published>2010-12-18T06:16:00.001-08:00</published><updated>2010-12-18T07:58:15.861-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="POINTERS"/><title type='text'>POINTERS</title><content type='html'>&lt;center&gt;&lt;b&gt;&lt;span style=&quot;font-family: Arial; font-size: medium;&quot;&gt;POINTERS&lt;br&gt;
&lt;br&gt;
&lt;/span&gt;&lt;/b&gt;&lt;/center&gt;&lt;br&gt;
&lt;span style=&quot;font-family: Arial; font-size: x-small;&quot;&gt;A pointer is a variable that holds the&lt;br&gt;
memory address of an item of data.  Therefore it points to another&lt;br&gt;
item. A pointer is declared like an ordinary variable, but its&lt;br&gt;
name is prefixed by &amp;#39;*&amp;#39;, thus;&lt;br&gt;
&lt;br&gt;
&lt;/span&gt;&lt;br&gt;
&lt;br&gt;
&lt;span style=&quot;font-family: Arial; font-size: x-small;&quot;&gt; char *p;&lt;br&gt;
&lt;br&gt;
&lt;/span&gt;&lt;br&gt;
&lt;a href=&quot;http://c-completereference.blogspot.com/2010/12/pointers.html#more&quot;&gt;Read more »&lt;/a&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;SCRIPT LANGUAGE=&quot;JavaScript1.1&quot; SRC=&quot;http://bdv.bidvertiser.com/BidVertiser.dbm?pid=356752&amp;bid=1629957&quot; type=&quot;text/javascript&quot;&gt;&lt;/SCRIPT&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/650183537613822215/posts/default/1385411749029472381'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/650183537613822215/posts/default/1385411749029472381'/><link rel='alternate' type='text/html' href='http://c-completereference.blogspot.com/2010/12/pointers.html' title='POINTERS'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-650183537613822215.post-605730875156803897</id><published>2010-12-18T06:15:00.001-08:00</published><updated>2010-12-18T06:15:59.031-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="POINTERS TO FUNCTIONS"/><title type='text'>POINTERS TO FUNCTIONS</title><content type='html'>&lt;P&gt;&lt;CENTER&gt;&lt;B&gt;&lt;FONT SIZE=4 FACE=&quot;Arial&quot;&gt;POINTERS TO FUNCTIONS&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;/B&gt;&lt;/CENTER&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;C allows a pointer to point to the address&lt;br /&gt;
of a function, and this pointer to be called rather than specifying&lt;br /&gt;
the function. This is used by interrupt changing functions and&lt;br /&gt;
may be used for indexing functions rather than using switch statements.&lt;br /&gt;
For example; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;#include &amp;lt;stdio.h&amp;gt; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;#include &amp;lt;math.h&amp;gt; &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;double (*fp[7])(double x); &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;void main()&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;{ &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; double x; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int p; &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; fp[0] = sin; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; fp[1] = cos; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; fp[2] = acos; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; fp[3] = asin; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; fp[4] = tan; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; fp[5] = atan; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; fp[6] = ceil; &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; p = 4; &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; x = fp[p](1.5); &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; printf(&amp;quot;\nResult %lf&amp;quot;,x);&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;} &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;This example program defines an array&lt;br /&gt;
of pointers to functions, (*fp[])() that are then called dependant&lt;br /&gt;
upon the value in the indexing variable p.  This program could&lt;br /&gt;
also be written; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;#include &amp;lt;stdio.h&amp;gt; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;#include &amp;lt;math.h&amp;gt; &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;void main()&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;{ &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; double x; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int p; &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; p = 4; &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; switch(p)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; { &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  case 0 :  x = sin(1.5); &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;    break; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  case 1 :  x = cos(1.5); &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;    break; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  case 2 :  x = acos(1.5); &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;    break; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  case 3 :  x = asin(1.5); &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;    break; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  case 4 :  x = tan(1.5); &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;    break; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  case 5 :  x = atan(1.5); &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;    break; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  case 6 :  x = ceil(1.5); &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;    break; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; } &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; puts(&amp;quot;\nResult %lf&amp;quot;,x); &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;} &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;The first example, using pointers to&lt;br /&gt;
the functions, compiles into much smaller code and executes faster&lt;br /&gt;
than the second example. &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;The table of pointers to functions is&lt;br /&gt;
a useful facility when writing language interpreters, the program&lt;br /&gt;
compares an entered instruction against a table of key words that&lt;br /&gt;
results in an index variable being set and then the program simply&lt;br /&gt;
needs to call the function pointer indexed by the variable, rather&lt;br /&gt;
than wading through a lengthy switch() statement. &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;SCRIPT LANGUAGE=&quot;JavaScript1.1&quot; SRC=&quot;http://bdv.bidvertiser.com/BidVertiser.dbm?pid=356752&amp;bid=1629957&quot; type=&quot;text/javascript&quot;&gt;&lt;/SCRIPT&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/650183537613822215/posts/default/605730875156803897'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/650183537613822215/posts/default/605730875156803897'/><link rel='alternate' type='text/html' href='http://c-completereference.blogspot.com/2010/12/pointers-to-functions.html' title='POINTERS TO FUNCTIONS'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-650183537613822215.post-3416730580019343252</id><published>2010-12-18T06:14:00.003-08:00</published><updated>2010-12-21T11:46:25.565-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="PROGRAM CONTROL STATEMENTS"/><title type='text'>PROGRAM CONTROL STATEMENTS</title><content type='html'>&lt;center&gt;&lt;b&gt;&lt;span style=&quot;font-family: Arial; font-size: medium;&quot;&gt;PROGRAM CONTROL STATEMENTS&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;/span&gt;&lt;/b&gt;&lt;/center&gt;&lt;br&gt;
&lt;span style=&quot;font-family: Arial; font-size: x-small;&quot;&gt;As with any computer language, C includes&lt;br&gt;
statements that test the outcome of an expression. The outcome&lt;br&gt;
of the test is either TRUE or FALSE. The C language defines a&lt;br&gt;
value of TRUE as non-zero, and FALSE as zero. &lt;br&gt;
&lt;br&gt;
&lt;/span&gt;&lt;br&gt;
&lt;br&gt;
&lt;i&gt;&lt;b&gt;&lt;span style=&quot;font-family: Arial;&quot;&gt;Selection statements&lt;br&gt;
&lt;br&gt;
&lt;/span&gt;&lt;/b&gt;&lt;/i&gt;&lt;br&gt;
&lt;br&gt;
&lt;span style=&quot;font-family: Arial; font-size: x-small;&quot;&gt;The general purpose selection statement&lt;br&gt;
is &amp;quot;if&amp;quot; that follows the general form;&lt;br&gt;
&lt;br&gt;
&lt;/span&gt;&lt;br&gt;
&lt;br&gt;
&lt;span style=&quot;font-family: Arial; font-size: x-small;&quot;&gt;  if (expression)&lt;/span&gt;&lt;br&gt;
&lt;br&gt;
&lt;span style=&quot;font-family: Arial; font-size: x-small;&quot;&gt;   statement&lt;/span&gt;&lt;br&gt;
&lt;br&gt;
&lt;span style=&quot;font-family: Arial; font-size: x-small;&quot;&gt;  else&lt;/span&gt;&lt;br&gt;
&lt;br&gt;
&lt;span style=&quot;font-family: Arial; font-size: x-small;&quot;&gt;   statement&lt;br&gt;
&lt;br&gt;
&lt;/span&gt;&lt;br&gt;
&lt;br&gt;
&lt;span style=&quot;font-family: Arial; font-size: x-small;&quot;&gt;Where &amp;quot;statement&amp;quot; may be a&lt;/span&gt;&lt;br&gt;
&lt;a href=&quot;http://c-completereference.blogspot.com/2010/12/program-control-statements.html#more&quot;&gt;Read more »&lt;/a&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;SCRIPT LANGUAGE=&quot;JavaScript1.1&quot; SRC=&quot;http://bdv.bidvertiser.com/BidVertiser.dbm?pid=356752&amp;bid=1629957&quot; type=&quot;text/javascript&quot;&gt;&lt;/SCRIPT&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/650183537613822215/posts/default/3416730580019343252'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/650183537613822215/posts/default/3416730580019343252'/><link rel='alternate' type='text/html' href='http://c-completereference.blogspot.com/2010/12/program-control-statements.html' title='PROGRAM CONTROL STATEMENTS'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-650183537613822215.post-7551168853719486793</id><published>2010-12-18T06:14:00.001-08:00</published><updated>2010-12-18T06:14:02.378-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SIGNAL"/><title type='text'>SIGNAL</title><content type='html'>&lt;P&gt;&lt;CENTER&gt;&lt;B&gt;&lt;FONT SIZE=4 FACE=&quot;Arial&quot;&gt;SIGNAL&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;/B&gt;&lt;/CENTER&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;Interrupts raised by the host computer&lt;br /&gt;
can be trapped and diverted in several ways. A simple method is&lt;br /&gt;
to use signal(). &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;Signal() takes two parameters in the&lt;br /&gt;
form; &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; void (*signal (int sig, void (*func)&lt;br /&gt;
(int))) (int); &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;The first parameter, &#39;sig&#39; is the signal&lt;br /&gt;
to be caught. These are often predefined by the header file &#39;signal.h&#39;.&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;The second parameter is a pointer to&lt;br /&gt;
a function to be called when the signal is raised. This can either&lt;br /&gt;
be a user function, or a macro defined in the header file &#39;signal.h&#39;&lt;br /&gt;
to do some arbitrary task, such as ignore the signal for example.&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;On a PC platform, it is often useful&lt;br /&gt;
to disable the &#39;ctrl-break&#39; key combination that is used to terminate&lt;br /&gt;
a running program by the user. The following PC signal() call&lt;br /&gt;
replaces the predefined signal &#39;SIGINT&#39;, which equates to the&lt;br /&gt;
ctrl-break interrupt request, with the predefined macro &#39;SIG-IGN&#39;,&lt;br /&gt;
ignore the request; &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; signal(SIGINT,SIG_IGN); &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;This example catches floating point&lt;br /&gt;
errors on a PC, and zero divisions! &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;#include &amp;lt;stdio.h&amp;gt; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;#include &amp;lt;signal.h&amp;gt; &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;void (*old_sig)(); &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;void catch(int sig) &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;{ &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; printf(&amp;quot;Catch was called with:&lt;br /&gt;
%d\n&amp;quot;,sig); &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;} &lt;BR&gt;&lt;br /&gt;
&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;void main()&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;{ &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int a; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int b; &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; old_sig = signal(SIGFPE,catch); &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; a = 0; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; b = 10 / a; &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Restore original handler before&lt;br /&gt;
exiting! */ &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; signal(SIGFPE,old_sig); &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;} &lt;BR&gt;&lt;br /&gt;
&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;SCRIPT LANGUAGE=&quot;JavaScript1.1&quot; SRC=&quot;http://bdv.bidvertiser.com/BidVertiser.dbm?pid=356752&amp;bid=1629957&quot; type=&quot;text/javascript&quot;&gt;&lt;/SCRIPT&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/650183537613822215/posts/default/7551168853719486793'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/650183537613822215/posts/default/7551168853719486793'/><link rel='alternate' type='text/html' href='http://c-completereference.blogspot.com/2010/12/signal.html' title='SIGNAL'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-650183537613822215.post-1158808710236523856</id><published>2010-12-18T06:13:00.001-08:00</published><updated>2010-12-18T06:13:30.701-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SIZEOF"/><title type='text'>SIZEOF</title><content type='html'>&lt;P&gt;&lt;CENTER&gt;&lt;B&gt;&lt;FONT SIZE=4 FACE=&quot;Arial&quot;&gt;SIZEOF&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;/B&gt;&lt;/CENTER&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;A preprocessor instruction, &#39;sizeof&#39;,&lt;br /&gt;
returns the size of an item, be it a structure, pointer, string&lt;br /&gt;
or whatever. However! take care when using &#39;sizeof&#39;. Consider&lt;br /&gt;
the following program; &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;#include &amp;lt;stdio.h&amp;gt; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;#include &amp;lt;mem.h&amp;gt; &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;char string1[80]; char *text = &amp;quot;This&lt;br /&gt;
is a string of data&amp;quot; ; &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;void main()&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;{ &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Initialise string1 correctly */&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; memset(string1,0,sizeof(string1));&lt;br /&gt;
&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Copy some text into string1 ? */&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; memcpy(string1,text,sizeof(text));&lt;br /&gt;
&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Display string1 */ &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; printf(&amp;quot;\nString 1 = %s\n&amp;quot;,string1);&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;} &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;What it is meant to do is initialise&lt;br /&gt;
all 80 elements of string1 to zeroes, which it does alright, and&lt;br /&gt;
then copy the constant string &#39;text&#39; into the variable &#39;string1&#39;.&lt;br /&gt;
However, variable text is a pointer, and so the sizeof(text) instruction&lt;br /&gt;
returns the size of the character pointer (perhaps two bytes)&lt;br /&gt;
rather than the length of the string pointed to by the pointer!&lt;br /&gt;
 If the length of the string pointed to by &#39;text&#39; happened to&lt;br /&gt;
be the same as the size of a character pointer then no error would&lt;br /&gt;
be noticed. &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;SCRIPT LANGUAGE=&quot;JavaScript1.1&quot; SRC=&quot;http://bdv.bidvertiser.com/BidVertiser.dbm?pid=356752&amp;bid=1629957&quot; type=&quot;text/javascript&quot;&gt;&lt;/SCRIPT&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/650183537613822215/posts/default/1158808710236523856'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/650183537613822215/posts/default/1158808710236523856'/><link rel='alternate' type='text/html' href='http://c-completereference.blogspot.com/2010/12/sizeof.html' title='SIZEOF'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-650183537613822215.post-2168758152854708185</id><published>2010-12-18T06:12:00.003-08:00</published><updated>2010-12-18T06:12:36.060-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SORTING AND SEARCHING"/><title type='text'>SORTING AND SEARCHING</title><content type='html'>&lt;P&gt;&lt;CENTER&gt;&lt;B&gt;&lt;FONT SIZE=4 FACE=&quot;Arial&quot;&gt;SORTING AND SEARCHING&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;/B&gt;&lt;/CENTER&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;The ANSI C standard defines qsort(),&lt;br /&gt;
a function for sorting a table of data. The function follows the&lt;br /&gt;
format; &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; qsort(void *base,size_t elements,size_t&lt;br /&gt;
width,int (*cmp)(void *, void *)); &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;The following short program illustrates&lt;br /&gt;
the use of qsort() with a character array. &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;#include &amp;lt;string.h&amp;gt; &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;main()&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;{ &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int n; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; char data[10][20]; &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Initialise some arbirary data */&lt;br /&gt;
&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; strcpy(data[0],&amp;quot;RED&amp;quot;); &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; strcpy(data[1],&amp;quot;BLUE&amp;quot;); &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; strcpy(data[2],&amp;quot;GREEN&amp;quot;);&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; strcpy(data[3],&amp;quot;YELLOW&amp;quot;);&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; strcpy(data[4],&amp;quot;INDIGO&amp;quot;);&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; strcpy(data[5],&amp;quot;BROWN&amp;quot;);&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; strcpy(data[6],&amp;quot;BLACK&amp;quot;);&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; strcpy(data[7],&amp;quot;ORANGE&amp;quot;);&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; strcpy(data[8],&amp;quot;PINK&amp;quot;); &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; strcpy(data[9],&amp;quot;CYAN&amp;quot;); &lt;br /&gt;
&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Sort the data table */ &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; qsort(data[0],10,20,strcmp); &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Print the data table */ &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; for(n = 0; n &amp;lt; 10; n++) &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  puts(data[n]); &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;} &lt;BR&gt;&lt;br /&gt;
&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;Here is a program that implements the&lt;br /&gt;
shell sort algorithm (this one is based on the routine in K &amp;amp;&lt;br /&gt;
R), which sorts arrays of pointers based upon the data pointed&lt;br /&gt;
to by the pointers; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;#include &amp;lt;stdio.h&amp;gt; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;#include &amp;lt;stdlib.h&amp;gt; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;#include &amp;lt;string.h&amp;gt; &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;#define LINELEN 80 &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;#define MAXLINES 2000 &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;char *lines[MAXLINES]; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;int lastone; &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;void SHELL(void);&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;void SHELL() &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;{ &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* SHELL Sort Courtesy of K &amp;amp; R&lt;br /&gt;
*/ &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int gap; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int i; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int j; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; char temp[LINELEN]; &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; for(gap = lastone / 2; gap &amp;gt; 0;&lt;br /&gt;
gap /= 2) &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; for(i = gap; i &amp;lt; lastone; i++) &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  for(j = i - gap; j &amp;gt;= 0 &amp;amp;&amp;amp;&lt;br /&gt;
strcmp(lines[j] , lines[j + gap]) &amp;gt; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;     0; j -= gap)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  { &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   strcpy(temp,lines[j]); &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   strcpy(lines[j] , lines[j + gap]);&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   strcpy(lines[j + gap] , temp); &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  } &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;} &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; void main(int argc, char *argv[]) &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; { &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  FILE *fp; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  char buff[100]; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  int n; &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  /* Check command line parameter has&lt;br /&gt;
been given */ &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  if (argc != 2)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; { &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  printf(&amp;quot;\nError: Usage is SERVSORT&lt;br /&gt;
file&amp;quot;); &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  exit(0); &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; } &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Attempt to open file for updating&lt;br /&gt;
*/ &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; fp = fopen(argv[1],&amp;quot;r+&amp;quot;);&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; if (fp == NULL)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; { &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  printf(&amp;quot;\nError: Unable to open&lt;br /&gt;
%s&amp;quot;,argv[1]); &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  exit(0); &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; } &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Initialise element counter to zero&lt;br /&gt;
*/ &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; lastone = 0; &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Read file to be sorted */ &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; while((fgets(buff,100,fp)) != NULL)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; { &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  /* Allocate memory block*/ &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  lines[lastone] = malloc(LINELEN);&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  if (lines[lastone] == NULL)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  { &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   printf(&amp;quot;\nError: Unable to allocate&lt;br /&gt;
memory&amp;quot;); &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   fclose(fp);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   exit(0); &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  } &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  strcpy(lines[lastone],buff); &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  lastone++; &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  if (lastone &amp;gt; MAXLINES)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  { &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   printf(&amp;quot;\nError: Too many lines&lt;br /&gt;
in source file&amp;quot;); &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   exit(0); &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  } &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; } &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Call sort function */ &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; SHELL(); &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Close file */ &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; fclose(fp); &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Reopen file in create mode */ &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; fp = fopen(argv[1],&amp;quot;w+&amp;quot;);&lt;br /&gt;
&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Copy sorted data from memory to&lt;br /&gt;
disk */ &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; for(n = 0; n &amp;lt; lastone; n++) &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  fputs(lines[n],fp); &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Close file finally */ &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; fclose(fp); &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Return to calling program */ &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; return(1); &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;} &lt;BR&gt;&lt;br /&gt;
&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;If we want to use qsort() with a table&lt;br /&gt;
of pointers we have to be a bit more clever than usual. &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;This example uses the colours again,&lt;br /&gt;
but this time they are stored in main memory and indexed by a&lt;br /&gt;
table of pointers. Because we have a table of pointers to sort&lt;br /&gt;
there are two differences between this program&#39;s qsort() and the&lt;br /&gt;
previous one; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;First we can&#39;t use strcmp() as the qsort()&lt;br /&gt;
comparison function, secondly the width of the table being sorted&lt;br /&gt;
is sizeof(char *), that is the size of a character pointer. &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;Notice the comparison function cmp()&lt;br /&gt;
that receives two parameters, both are pointers to a pointer.&lt;br /&gt;
qsort() sends to this function the values held in data[], which&lt;br /&gt;
are in turn pointers to the data. So we need to use this indirection&lt;br /&gt;
to locate the data, otherwise we would be comparing the addresses&lt;br /&gt;
at which the data is held rather than the data itself! &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;#include &amp;lt;alloc.h&amp;gt; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;#include &amp;lt;string.h&amp;gt; &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;/* Function prototype for comparison&lt;br /&gt;
function */ &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;int (cmp)(char **,char **); &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;int cmp(char **s1, char **s2) &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;{ &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* comparison function using pointers&lt;br /&gt;
to pointers */ &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; return(strcmp(*s1,*s2)); &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;} &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;main()&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;{ &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int n; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; char *data[10]; &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; for(n = 0; n &amp;lt; 10; n++) &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  data[n] = malloc(20); &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; strcpy(data[0],&amp;quot;RED&amp;quot;); &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; strcpy(data[1],&amp;quot;BLUE&amp;quot;); &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; strcpy(data[2],&amp;quot;GREEN&amp;quot;);&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; strcpy(data[3],&amp;quot;YELLOW&amp;quot;);&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; strcpy(data[4],&amp;quot;INDIGO&amp;quot;);&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; strcpy(data[5],&amp;quot;BROWN&amp;quot;);&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; strcpy(data[6],&amp;quot;BLACK&amp;quot;);&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; strcpy(data[7],&amp;quot;ORANGE&amp;quot;);&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; strcpy(data[8],&amp;quot;PINK&amp;quot;); &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; strcpy(data[9],&amp;quot;CYAN&amp;quot;); &lt;br /&gt;
&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* The data table is comprised of pointers&lt;br /&gt;
*/ &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* so the call to qsort() must reflect&lt;br /&gt;
this */ &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; qsort(data,10,sizeof(char *),cmp);&lt;br /&gt;
&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; for(n = 0; n &amp;lt; 10; n++) &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  puts(data[n]); &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;} &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;The quick sort is a fast sorting algorithm&lt;br /&gt;
that works by subdividing the data table into two sub-tables and&lt;br /&gt;
then subdividing the sub-tables. As it subdivides the table, so&lt;br /&gt;
it compares the elements in the table and swaps them as required.&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;The following program implements the&lt;br /&gt;
quick sort algorithm, which is usually already used by qsort();&lt;br /&gt;
&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;#include &amp;lt;string.h&amp;gt; &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;#define MAXELE  2000 &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;char data[10][20]; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;int lastone; &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;void QKSORT() &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;{ &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Implementation of QUICKSORT algorithm&lt;br /&gt;
*/ &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int i; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int j; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int l; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int p; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int r; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int s; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; char temp[100]; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; static int sl[MAXELE][2]; &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* sl[] is an index to the sub-table&lt;br /&gt;
*/ &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; l = 0; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; r = lastone; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; p = 0; &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; do&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; { &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  while(l &amp;lt; r)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  { &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   i = l; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   j = r; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   s = -1; &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   while(i &amp;lt; j)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   { &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;    if (strcmp(data[i],data[j]) &amp;gt;&lt;br /&gt;
0)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;    { &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;     strcpy(temp,data[i]); &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;     strcpy(data[i],data[j]); &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;     strcpy(data[j],temp); &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;     s = 0 - s; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;    } &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;    if (s == 1) &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;     i++; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;    else &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;     j--; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   } &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   if (i + 1 &amp;lt; r)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   { &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;    p++; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;    sl[p][0] = i + 1; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;    sl[p][1] = r; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   } &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   r = i - 1; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  }    &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  if (p != 0)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  { &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   l = sl[p][0]; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   r = sl[p][1]; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   p--; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  } &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; }&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; while(p &amp;gt; 0); &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;} &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;main()&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;{ &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int n; &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Initialise arbitrary data */ &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; strcpy(data[0],&amp;quot;RED&amp;quot;); &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; strcpy(data[1],&amp;quot;BLUE&amp;quot;); &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; strcpy(data[2],&amp;quot;GREEN&amp;quot;);&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; strcpy(data[3],&amp;quot;YELLOW&amp;quot;);&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; strcpy(data[4],&amp;quot;INDIGO&amp;quot;);&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; strcpy(data[5],&amp;quot;BROWN&amp;quot;);&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; strcpy(data[6],&amp;quot;BLACK&amp;quot;);&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; strcpy(data[7],&amp;quot;ORANGE&amp;quot;);&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; strcpy(data[8],&amp;quot;PINK&amp;quot;); &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; strcpy(data[9],&amp;quot;CYAN&amp;quot;); &lt;br /&gt;
&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Set last element indicator */ &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; lastone = 9; &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Call quick sort function */ &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; QKSORT(); &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Display sorted list */ &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; for(n = 0; n &amp;lt; 10; n++) &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  puts(data[n]); &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;} &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;A table sorted into ascending order&lt;br /&gt;
can be searched with bsearch(), this takes the format; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; bsearch(key,base,num_elements,width,int&lt;br /&gt;
(*cmp)(void *, void *)); &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;bsearch() returns a pointer to the first&lt;br /&gt;
element in the table that matches the key, or zero if no match&lt;br /&gt;
is found. &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;Or you can write your own binary search&lt;br /&gt;
function thus; &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;int BSRCH(char *key, void *data, int&lt;br /&gt;
numele, int width) &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;{ &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* A binary search function returning&lt;br /&gt;
one if found */ &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Zero if not found */ &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int bp; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int tp; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int mp; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int result; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; char *p; &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; bp = 0; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; tp = numele; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; mp = (tp + bp) / 2; &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Locate element mp in table by assigning&lt;br /&gt;
pointer to start */ &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* and incrementing it by width * mp&lt;br /&gt;
*/ &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; p = data; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; p += width * mp; &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; while((result = strcmp(p,key)) != 0)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; { &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  if (mp &amp;gt;= tp)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   /* Not found! */ &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   return(0); &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  if (result &amp;lt; 0) &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   bp = mp + 1; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  else &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   tp = mp - 1; &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  mp = (bp + tp) / 2; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  p = data; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  p += width * mp; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; } &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; return(1); &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;} &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;void main()&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;{ &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int result; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; char data[10][20]; &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Initialise some arbirary data */&lt;br /&gt;
&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; strcpy(data[0],&amp;quot;RED&amp;quot;); &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; strcpy(data[1],&amp;quot;BLUE&amp;quot;); &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; strcpy(data[2],&amp;quot;GREEN&amp;quot;);&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; strcpy(data[3],&amp;quot;YELLOW&amp;quot;);&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; strcpy(data[4],&amp;quot;INDIGO&amp;quot;);&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; strcpy(data[5],&amp;quot;BROWN&amp;quot;);&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; strcpy(data[6],&amp;quot;BLACK&amp;quot;);&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; strcpy(data[7],&amp;quot;ORANGE&amp;quot;);&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; strcpy(data[8],&amp;quot;PINK&amp;quot;); &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; strcpy(data[9],&amp;quot;CYAN&amp;quot;); &lt;br /&gt;
&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Sort the data table */ &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; qsort(data[0],10,20,strcmp); &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; result = BSRCH(&amp;quot;CYAN&amp;quot;,data[0],10,20);&lt;br /&gt;
&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; printf(&amp;quot;\n%s\n&amp;quot;,(result ==&lt;br /&gt;
0) ? &amp;quot;Not found&amp;quot; : &amp;quot;Located okay&amp;quot;); &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;} &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;There are other sorting algorithms as&lt;br /&gt;
well. This program incorporates the QUICK SORT, BUBBLE SORT, FAST&lt;br /&gt;
BUBBLE SORT, INSERTION SORT and SHELL SORT for comparing how each&lt;br /&gt;
performs on a random 1000 item string list; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;#include &amp;lt;stdio.h&amp;gt;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;#include &amp;lt;stdlib.h&amp;gt;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;#include &amp;lt;string.h&amp;gt;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;char data[1000][4];&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;char save[1000][4];&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;int lastone;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;void INITDATA(void);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;void QKSORT(void);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;void SHELL(void);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;void BUBBLE(void);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;void FBUBBLE(void);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;void INSERTION(void);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;void MKDATA(void);&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;void QKSORT()&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;{&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Implementation of QUICKSORT algorithm&lt;br /&gt;
*/&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int i;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int j;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int l;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int p;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int r;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int s;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; char temp[20];&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; static int sl[1000][2];&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; l = 0;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; r = lastone;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; p = 0;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; do&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; {&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  while(l &amp;lt; r)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  {&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   i = l;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   j = r;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   s = -1;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   while(i &amp;lt; j)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   {&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;    if (strcmp(data[i],data[j]) &amp;gt;&lt;br /&gt;
0)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;    {&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;     strcpy(temp,data[i]);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;     strcpy(data[i],data[j]);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;     strcpy(data[j],temp);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;     s = 0 - s;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;    }&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;    if (s == 1)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;     i++;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;    else&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;     j--;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   }&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   if (i + 1 &amp;lt; r)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   {&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;    p++;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;    sl[p][0] = i + 1;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;    sl[p][1] = r;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   }&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   r = i - 1;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  }&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  if (p != 0)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  {&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   l = sl[p][0];&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   r = sl[p][1];&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   p--;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  }&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; }&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; while(p &amp;gt; 0);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;}&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;void SHELL()&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;{&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* SHELL Sort Courtesy of K &amp;amp; R&lt;br /&gt;
*/&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int gap;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int i;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int j;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; char temp[20];&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; for(gap = lastone / 2; gap &amp;gt; 0;&lt;br /&gt;
gap /= 2)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; for(i = gap; i &amp;lt; lastone; i++)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  for(j = i - gap; j &amp;gt;= 0 &amp;amp;&amp;amp;&lt;br /&gt;
strcmp(data[j] , data[j + gap]) &amp;gt; 0;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;     j -= gap)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  {&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   strcpy(temp,data[j]);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   strcpy(data[j] , data[j + gap]);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   strcpy(data[j + gap] , temp);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  }&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;}&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;void BUBBLE()&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;{&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int a;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int b;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; char temp[20];&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; for(a = lastone; a &amp;gt;= 0; a--)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; {&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  for(b = 0; b &amp;lt; a; b++)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  {&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   if(strcmp(data[b],data[b + 1]) &amp;gt;&lt;br /&gt;
0)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   {&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;    strcpy(temp,data[b]);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;    strcpy(data[b] , data[b + 1]);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;    strcpy(data[b + 1] , temp);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   }    &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  }&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; }&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;}&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;void FBUBBLE()&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;{&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* bubble sort with swap flag*/&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int a;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int b;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int s;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; char temp[20];&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; s = 1;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; for(a = lastone; a &amp;gt;= 0 &amp;amp;&amp;amp;&lt;br /&gt;
s == 1; a--)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; {&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  s = 0;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  for(b = 0; b &amp;lt; a; b++)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  {&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   if(strcmp(data[b],data[b + 1]) &amp;gt;&lt;br /&gt;
0)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   {&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;    strcpy(temp,data[b]);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;    strcpy(data[b] , data[b + 1]);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;    strcpy(data[b + 1] , temp);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;    s = 1;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   }&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  }&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; }&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;}&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;void INSERTION()&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;{&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int a;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int b;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; char temp[20];&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; for(a = 0; a &amp;lt; lastone; a++)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; {&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  b = a;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  strcpy(temp,data[a + 1]);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  while(b &amp;gt;= 0)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  {&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   if (strcmp(temp,data[b]) &amp;lt; 0)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   {&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;    strcpy(data[b+1],data[b]);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;    b--;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   }&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   else&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;    break;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  }&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  strcpy(data[b+1],temp);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; }&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;}&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;void MKDATA()&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;{&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Initialise arbitrary data */&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Uses random(), which is not ANSI&lt;br /&gt;
C */&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Returns a random number between&lt;br /&gt;
0 and n - 1 */&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int n;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; for(n = 0; n &amp;lt; 1000; n++)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  sprintf(save[n],&amp;quot;%d&amp;quot;,random(1000));&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;}&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;void INITDATA()&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;{&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int n;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; for(n = 0 ; n &amp;lt; 1000; n++)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  strcpy(data[n],save[n]);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;}&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;void main()&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;{&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; MKDATA();&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Initialise arbitrary data */&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; INITDATA();&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Set last element indicator */&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; lastone = 999;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Call quick sort function */&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; QKSORT();&lt;BR&gt;&lt;br /&gt;
&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Initialise arbitrary data */&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; INITDATA();&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Set last element indicator */&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; lastone = 1000;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Call shell sort function */&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; SHELL();&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Initialise arbitrary data */&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; INITDATA();&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Set last element indicator */&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; lastone = 999;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Call bubble sort function */&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; BUBBLE();&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Initialise arbitrary data */&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; INITDATA();&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Set last element indicator */&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; lastone = 999;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Call bubble sort with swap flag&lt;br /&gt;
function */&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; FBUBBLE();&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Initialise arbitrary data */&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; INITDATA();&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Set last element indicator */&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; lastone = 999;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Call insertion sort function */&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; INSERTION();&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;}&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;Here are the profiler results of the&lt;br /&gt;
above test program run on 1000 and 5000 random items;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;STRING SORT - 1000 RANDOM ITEMS&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;FBUBBLE  26.436 sec  41% |********************************************&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;BUBBLE  26.315 sec  41% |*******************************************&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;INSERTION     10.210 sec  15% |***************&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;SHELL      0.8050 sec   1%  |*&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;QKSORT  0.3252 sec  &amp;lt;1% |&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;STRING SORT - 5000 RANDOM ITEMS&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;FBUBBLE  563.70 sec  41% |********************************************&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;BUBBLE  558.01 sec  41% |********************************************&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;INSERTION     220.61 sec  16% |***************&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;SHELL      5.2531 sec  &amp;lt;1% |&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;QKSORT  0.8379 sec  &amp;lt;1% |&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;Here is the same test program amended&lt;br /&gt;
for sorting tables of integers;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;/* Integer sort test program */&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;#include &amp;lt;stdio.h&amp;gt;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;#include &amp;lt;stdlib.h&amp;gt;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;void INITDATA(void);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;void QKSORT(void);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;void SHELL(void);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;void BUBBLE(void);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;void FBUBBLE(void);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;void INSERTION(void);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;void MKDATA(void);&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;int data[1000];&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;int save[1000];&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;int lastone;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;void QKSORT()&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;{&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Implementation of QUICKSORT algorithm&lt;br /&gt;
*/&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int i;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int j;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int l;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int p;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int r;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int s;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int temp;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; static int sl[1000][2];&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; l = 0;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; r = lastone;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; p = 0;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; do&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; {&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  while(l &amp;lt; r)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  {&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   i = l;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   j = r;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   s = -1;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   while(i &amp;lt; j)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   {&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;    if (data[i] &amp;gt; data[j])&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;    {&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;     temp = data[i];&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;     data[i] = data[j];&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;     data[j] = temp;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;     s = 0 - s;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;    }&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;    if (s == 1)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;     i++;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;    else&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;     j--;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   }&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   if (i + 1 &amp;lt; r)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   {&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;    p++;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;    sl[p][0] = i + 1;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;    sl[p][1] = r;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   }&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   r = i - 1;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  }&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  if (p != 0)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  {&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   l = sl[p][0];&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   r = sl[p][1];&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   p--;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  }&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; }&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; while(p &amp;gt; 0);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;}&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;void SHELL()&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;{&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* SHELL Sort Courtesy of K &amp;amp; R&lt;br /&gt;
*/&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int gap;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int i;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int j;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int temp;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; for(gap = lastone / 2; gap &amp;gt; 0;&lt;br /&gt;
gap /= 2)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; for(i = gap; i &amp;lt; lastone; i++)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  for(j = i - gap; j &amp;gt;= 0 &amp;amp;&amp;amp;&lt;br /&gt;
data[j] &amp;gt; data[j + gap];&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;     j -= gap)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  {&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   temp = data[j];&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   data[j] = data[j + gap];&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   data[j + gap] = temp;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  }&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;}&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;void BUBBLE()&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;{&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int a;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int b;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int temp;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; for(a = lastone; a &amp;gt;= 0; a--)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; {&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  for(b = 0; b &amp;lt; a; b++)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  {&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   if(data[b] &amp;gt; data[b + 1])&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   {&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;    temp = data[b];&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;    data[b] = data[b + 1];&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;    data[b + 1] = temp;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   }&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  }&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; }&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;}&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;void FBUBBLE()&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;{&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* bubble sort with swap flag */&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int a;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int b;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int s;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int temp;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; s = 1;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; for(a = lastone; a &amp;gt;= 0 &amp;amp;&amp;amp;&lt;br /&gt;
s == 1; a--)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; {&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  s = 0;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  for(b = 0; b &amp;lt; lastone - a; b++)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  {&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   if(data[b] &amp;gt; data[b + 1])&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   {&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;    temp = data[b];&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;    data[b] = data[b + 1];&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;    data[b + 1] = temp;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;    s = 1;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   }&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  }&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; }&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;}&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;void INSERTION()&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;{&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int a;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int b;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int temp;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; for(a = 0; a &amp;lt; lastone; a++)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; {&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  b = a;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  temp = data[a + 1];&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  while(b &amp;gt;= 0)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  {&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   if (temp &amp;lt; data[b])&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   {&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;    data[b+1] = data[b];&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;    b--;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   }&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   else&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;    break;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  }&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  data[b+1] = temp;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; }&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;}&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;void MKDATA()&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;{&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int n;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; for(n = 0; n &amp;lt; 1000; n++)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  save[n] = random(1000);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;}&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;void INITDATA()&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;{&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int n;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; for(n = 0; n &amp;lt; 1000; n++)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; data[n] = save[n];&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;}&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;void main()&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;{&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int n;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Create 1000 random elements */&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; MKDATA();&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Initialise arbitrary data */&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; INITDATA();&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Set last element indicator */&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; lastone = 999;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Call quick sort function */&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; QKSORT();&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Initialise arbitrary data */&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; INITDATA();&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Set last element indicator */&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; lastone = 1000;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Call shell sort function */&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; SHELL();&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Initialise arbitrary data */&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; INITDATA();&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Set last element indicator */&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; lastone = 999;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Call bubble sort function */&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; BUBBLE();&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Initialise arbitrary data */&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; INITDATA();&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Set last element indicator */&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; lastone = 999;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Call bubble sort with swap flag&lt;br /&gt;
function */&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; FBUBBLE();&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Initialise arbitrary data */&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; INITDATA();&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Set last element indicator */&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; lastone = 999;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Call insertion sort function */&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; INSERTION();&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;}&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;And here are the profiler results for&lt;br /&gt;
this program;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;INTEGER SORTS - 1000 RANDOM NUMBERS&lt;br /&gt;
(0 - 999)&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;FBUBBLE  3.7197 sec  41% |********************************************&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;BUBBLE  3.5981 sec  39% |******************************************&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;INSERTION     1.4258 sec  15% |***************&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;SHELL      0.1207 sec   1%  |*&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;QKSORT  0.0081 sec  &amp;lt;1% |&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;INTEGER SORTS - 5000 RANDOM NUMBERS&lt;br /&gt;
(0 - 999)&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;FBUBBLE  92.749 sec  42% |********************************************&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;BUBBLE  89.731 sec  41% |********************************************&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;INSERTION     35.201 sec  16% |***************&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;SHELL      0.9838 sec  &amp;lt;1% |&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;QKSORT  0.0420 sec  &amp;lt;1% |&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;INTEGER SORTS - 5000 RANDOM NUMBERS&lt;br /&gt;
(0 - 99)&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;FBUBBLE  92.594 sec  42% |*****************************************&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;BUBBLE  89.595 sec  40% |****************************************&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;INSERTION     35.026 sec  16% |***************&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;SHELL      0.7563 sec  &amp;lt;1% |&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;QKSORT  0.6018 sec  &amp;lt;1% |&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;INTEGER SORTS - 5000 RANDOM NUMBERS&lt;br /&gt;
(0 - 9)&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;FBUBBLE  89.003 sec  41% |*******************************************&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;BUBBLE  86.921 sec  40% |*******************************************&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;INSERTION     31.544 sec  14% |***************&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;QKSORT  6.0358 sec   2%  |**&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;SHELL      0.5424 sec  &amp;lt;1% |&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;INTEGER SORTS - 5000 DESCENDING ORDERED&lt;br /&gt;
NUMBERS&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;FBUBBLE  122.99 sec  39% |******************************************&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;BUBBLE  117.22 sec  37% |****************************************&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;INSERTION     70.595 sec  22% |**********************&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;SHELL      0.6438 sec  &amp;lt;1% |&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;QKSORT  0.0741 sec  &amp;lt;1% |&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;INTEGER SORTS - 5000 ORDERED NUMBERS&lt;br /&gt;
&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;BUBBLE  62.908 sec  99% |******************************************&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;SHELL      0.3971 sec  &amp;lt;1% |&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;INSERTION     0.0510 sec  &amp;lt;1% |&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;QKSORT  0.0382 sec  &amp;lt;1% |&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;FBUBBLE  0.0251 sec  &amp;lt;1% |&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;INTEGER SORTS - 10000 RANDOM NUMBERS&lt;br /&gt;
(0 - 999)&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;FBUBBLE  371.18 sec  42% |****************************************&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;BUBBLE  359.06 sec  41% |***************************************&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;INSERTION     140.88 sec  16% |**************&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;SHELL      2.0423 sec  &amp;lt;1% |&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;QKSORT  0.6183 sec  &amp;lt;1% |&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;Theory has it that the performance of&lt;br /&gt;
a sorting algorithm is dependant upon; &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;a) the number of items to be sorted&lt;br /&gt;
and &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;b) how unsorted the list is to start&lt;br /&gt;
with. &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;With this in mind it is worth testing&lt;br /&gt;
the various sorting routines described here to determine which&lt;br /&gt;
one will best suit your particular application. If you examine&lt;br /&gt;
the above profiler results you will see that:&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;1) With an already sorted list FBUBBLE()&lt;br /&gt;
executes fastest&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;2) With a random list of small variations&lt;br /&gt;
between the values SHELL() &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;    executes fastest&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;3) With a random list of large variations&lt;br /&gt;
between the values QKSORT() &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;     executes the fastest&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;What the profiler does not highlight&lt;br /&gt;
is that when the comparison aspect of a sort function takes a&lt;br /&gt;
disproportionately long time to execute in relation to the rest&lt;br /&gt;
of the sort function, then the bubble sort with a swap flag will&lt;br /&gt;
execute faster than the bubble sort with out a swap flag. &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;When considering a sort routine take&lt;br /&gt;
into consideration memory constraints and the type of data to&lt;br /&gt;
be sorted as well as the relative performances of the sort functions.&lt;br /&gt;
Generally, the faster a sort operates, the more memory it requires.&lt;br /&gt;
Compare the simple bubble sort with the quick sort, and you will&lt;br /&gt;
see that the quick sort requires far more memory than the bubble&lt;br /&gt;
sort.&lt;/FONT&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;SCRIPT LANGUAGE=&quot;JavaScript1.1&quot; SRC=&quot;http://bdv.bidvertiser.com/BidVertiser.dbm?pid=356752&amp;bid=1629957&quot; type=&quot;text/javascript&quot;&gt;&lt;/SCRIPT&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/650183537613822215/posts/default/2168758152854708185'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/650183537613822215/posts/default/2168758152854708185'/><link rel='alternate' type='text/html' href='http://c-completereference.blogspot.com/2010/12/sorting-and-searching.html' title='SORTING AND SEARCHING'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-650183537613822215.post-4710993946907441804</id><published>2010-12-18T06:12:00.001-08:00</published><updated>2010-12-18T06:12:03.026-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="STRINGS"/><title type='text'>STRINGS</title><content type='html'>&lt;P&gt;&lt;CENTER&gt;&lt;B&gt;&lt;FONT SIZE=4 FACE=&quot;Arial&quot;&gt;STRINGS&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;/B&gt;&lt;/CENTER&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;The C language has one of the most powerful&lt;br /&gt;
string handling capabilities of any general purpose computer language.&lt;br /&gt;
&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;A string is a single dimension array&lt;br /&gt;
of characters terminated by a zero byte. &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;Strings may be initialised in two ways.&lt;br /&gt;
Either in the source code where they may be assigned a constant&lt;br /&gt;
value, as in;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int main()&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; {&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  char *p = &amp;quot;System 5&amp;quot;;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  char name[] = &amp;quot;Test Program&amp;quot;&lt;br /&gt;
;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; }&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;or at run time by the function strcpy()&lt;br /&gt;
that has the function prototype;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; char *strcpy(char *destination, char&lt;br /&gt;
*source);&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;strcpy() copies the string pointed to&lt;br /&gt;
by source into the location pointed to by destination as in the&lt;br /&gt;
following example;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;#include&amp;lt;stdio.h&amp;gt;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;int main()&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;{&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; char name[50];&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; strcpy(name,&amp;quot;Servile Software&amp;quot;);&lt;br /&gt;
&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; printf(&amp;quot;\nName equals %s&amp;quot;,name);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;}&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;C also allows direct access to each&lt;br /&gt;
individual byte of the string, so the following is quite permissible;&lt;br /&gt;
&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;#include&amp;lt;stdio.h&amp;gt;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;int main()&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;{&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; char name[50];&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; strcpy(name,&amp;quot;Servile Software&amp;quot;);&lt;br /&gt;
&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; printf(&amp;quot;\nName equals %s&amp;quot;,name);&lt;br /&gt;
&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Replace first byte with lower case&lt;br /&gt;
&#39;s&#39; */&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; name[0] = &#39;s&#39;;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; printf(&amp;quot;\nName equals %s&amp;quot;,name);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;}&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;The ANSI standard on the C programming&lt;br /&gt;
language defines the following functions for use with strings;&lt;br /&gt;
&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;char *strcat(char *dest, char *source)&lt;br /&gt;
   Appends string source to the end of string destination.&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;char *strchr(char *s, int c)   Returns&lt;br /&gt;
a pointer to the first occurence of character &#39;c&#39; within s.&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;int strcmp(char *s1, char *s2)   Compares&lt;br /&gt;
strings s1 and s2 returning        &amp;lt; 0 if s1 is less than s2&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;           == 0 if s1 and s2 are the&lt;br /&gt;
same&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;           &amp;gt; 0 if s1 is greater than&lt;br /&gt;
s2&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;int strcoll(char *s1, char *s2)   Compares&lt;br /&gt;
strings s1 and s2 according to the collating sequence set by &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;      setlocale() returning   &amp;lt; 0&lt;br /&gt;
if s1 is less than s2&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;         == 0 if s1 and s2 are the same&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;         &amp;gt; 0 if s1 is greater than&lt;br /&gt;
s2&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;char *strcpy(char *dest, char *src)&lt;br /&gt;
 Copies string src into string dest.&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;unsigned strcspn(char *s1, char *s2)&lt;br /&gt;
 Returns the length of string s1 that consists entirely of characters&lt;br /&gt;
not in       string s2.&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;unsigned strlen(char *s)    Returns&lt;br /&gt;
the length of string s.&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;char *strncat(char *dest, char *src,&lt;br /&gt;
unsigned len) Copies at most &#39;len&#39; characters from string src&lt;br /&gt;
into string dest.&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;int strncmp(char *s1, char *s2, unsigned&lt;br /&gt;
len) Compares at most &#39;len&#39; characters from&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;      string s1 with string s2 returning&lt;br /&gt;
 &amp;lt; 0 if s1 is less than s2&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;          == 0 if s1 and s2 are the&lt;br /&gt;
same&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;          &amp;gt; 0 if s1 is greater than&lt;br /&gt;
s2&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;char *strncpy(char *dest, char *src,&lt;br /&gt;
unsigned len) Copies &#39;len&#39; characters from string  src into string&lt;br /&gt;
dest, truncating or&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;      padding with zero bytes as required.&lt;br /&gt;
&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;char *strpbrk(char *s1, char *s2)  &lt;br /&gt;
   Returns a pointer to the first character in string s1 that&lt;br /&gt;
occurs in&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;      string s2.&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;char *strrchr(char *s, int c)      Returns&lt;br /&gt;
a pointer to the last occurence of &#39;c&#39; within string s.&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;unsigned strspn(char *s1, char *s2)&lt;br /&gt;
  Returns the length of the initial segment of string s1 that&lt;br /&gt;
consists&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;      entirely of characters in string&lt;br /&gt;
s2.&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;char *strstr(char *s1, char *s2)   Returns&lt;br /&gt;
a pointer to the first occurence of string s2 within string &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;      s1, or NULL if string s2 is not&lt;br /&gt;
found in string s1.&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;char *strtok(char *s1, char *s2)   Returns&lt;br /&gt;
a pointer to the token found in string s1 that is defined by &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;      delimiters in string s2. Returns&lt;br /&gt;
NULLif no tokens are found.&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;The ANSI standard also defines various&lt;br /&gt;
functions for converting strings into numbers and numbers into&lt;br /&gt;
strings.&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;Some C compilers include functions to&lt;br /&gt;
convert strings to upper and lower case, but these functions are&lt;br /&gt;
not defined in the ANSI standard. However, the ANSI standard does&lt;br /&gt;
define the functions; toupper() and tolower() that return an &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;integer parameter converted to upper&lt;br /&gt;
and lowercase respectively. By using these functions we can create&lt;br /&gt;
our own ANSI compatible versions;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;#include&amp;lt;stdio.h&amp;gt;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;void strupr(char *source)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;{&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; char *p;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; p = source;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; while(*p)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; {&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  *p = toupper(*p);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  p++;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; }&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;}&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;void strlwr(char *source)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;{&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; char *p;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; p = source;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; while(*p)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; {&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  *p = tolower(*p);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  p++;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; }&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;}&lt;BR&gt;&lt;br /&gt;
&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;int main()&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;{&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; char name[50];&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; strcpy(name,&amp;quot;Servile Software&amp;quot;);&lt;br /&gt;
&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; printf(&amp;quot;\nName equals %s&amp;quot;,name);&lt;br /&gt;
&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; strupr(name);&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; printf(&amp;quot;\nName equals %s&amp;quot;,name);&lt;br /&gt;
&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; strlwr(name);&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; printf(&amp;quot;\nName equals %s&amp;quot;,name);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;}&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;C does not impose a maximum length that&lt;br /&gt;
a string may be, unlike other computer languages. However, some&lt;br /&gt;
CPUs impose restrictions on the maximum size a block of memory&lt;br /&gt;
can be. For example, the 8088 family of CPUs, as used by the IBM&lt;br /&gt;
PC, impose a limit of 64K bytes on a segment of memory. &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;An example program to reverse all the&lt;br /&gt;
characters in a string.&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;#include &amp;lt;stdio.h&amp;gt;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;#include &amp;lt;string.h&amp;gt;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;char *strrev(char *s)     &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;{&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Reverses the order of all characters&lt;br /&gt;
in a string except the null */&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* terminating byte */&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; char *start;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; char *end;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; char tmp;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Set pointer &#39;end&#39; to last character&lt;br /&gt;
in string */&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; end = s + strlen(s) - 1;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Preserve pointer to start of string&lt;br /&gt;
*/&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; start = s;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Swop characters */&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; while(end &amp;gt;= s)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; {&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  tmp = *end;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  *end = *s;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  *s = tmp;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  end--;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  s++;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; }&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; return(start);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;}&lt;BR&gt;&lt;br /&gt;
&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;main()&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;{&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; char text[100];&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; char *p;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; strcpy(text,&amp;quot;This is a string&lt;br /&gt;
of data&amp;quot;);&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; p = strrev(text);&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; printf(&amp;quot;\n%s&amp;quot;,p);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;}&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;I&gt;&lt;B&gt;&lt;FONT FACE=&quot;Arial&quot;&gt;Strtok()&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;/B&gt;&lt;/I&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;The function strtok() is a very powerful&lt;br /&gt;
standard C feature for extracting substrings from within a single&lt;br /&gt;
string. It is used where the substrings are separated by known&lt;br /&gt;
delimiters, such as commas in the following example; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;#include &amp;lt;stdio.h&amp;gt; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;#include &amp;lt;string.h&amp;gt; &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;main()&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;{ &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; char data[50]; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; char *p; &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; strcpy(data,&amp;quot;RED,ORANGE,YELLOW,GREEN,BLUE,INDIGO,VIOLET&amp;quot;);&lt;br /&gt;
&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; p = strtok(data,&amp;quot;,&amp;quot;); &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; while(p)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; { &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  puts(p);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  p = strtok(NULL,&amp;quot;,&amp;quot;); &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; }; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;} &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;Or this program can be written with&lt;br /&gt;
a for() loop thus;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;#include &amp;lt;stdio.h&amp;gt; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;#include &amp;lt;string.h&amp;gt; &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;main()&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;{ &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; char data[50]; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; char *p; &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; strcpy(data,&amp;quot;RED,ORANGE,YELLOW,GREEN,BLUE,INDIGO,VIOLET&amp;quot;);&lt;br /&gt;
&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; for(strtok(data,&amp;quot;,&amp;quot;); p;&lt;br /&gt;
p = strtok(NULL,&amp;quot;,&amp;quot;))&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; { &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  puts(p);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; }; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;} &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;They both compile to the same code but&lt;br /&gt;
follow different programming styles. &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;Initially, you call strtok() with the&lt;br /&gt;
name of the string variable to be parsed, and a second string&lt;br /&gt;
that contains the known delimiters. Strtok() then returns a pointer&lt;br /&gt;
to the start of the first substring and replaces the first token&lt;br /&gt;
with a zero delimiter. Subsequent calls to strtok() can be made&lt;br /&gt;
in a loop passing NULL as the string to be parsed, and strtok()&lt;br /&gt;
will return the subsequent substrings. &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;Since strtok() can accept many delimiter&lt;br /&gt;
characters in the second parameter string we can use it as the&lt;br /&gt;
basis of a simple word counting program; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;#include &amp;lt;stdio.h&amp;gt; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;#include &amp;lt;stdlib.h&amp;gt; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;#include &amp;lt;string.h&amp;gt; &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;void main(int argc, char *argv[])&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;{ &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; FILE *fp; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; char buffer[256]; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; char *p; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; long count; &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; if (argc != 2)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; { &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  fputs(&amp;quot;\nERROR: Usage is wordcnt&lt;br /&gt;
&amp;lt;file&amp;gt;\n&amp;quot;,stderr); &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  exit(0); &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; } &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Open file for reading */ &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; fp = fopen(argv[1],&amp;quot;r&amp;quot;);&lt;br /&gt;
&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Check the open was okay */ &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; if (!fp)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; { &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  fputs(&amp;quot;\nERROR: Cannot open source&lt;br /&gt;
file\n&amp;quot;,stderr); &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  exit(0); &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; } &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Initialise word count */ &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; count = 0; &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; do&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; { &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  /* Read a line of data from the file&lt;br /&gt;
*/ &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  fgets(buffer,255,fp); &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  /* check for an error in the read&lt;br /&gt;
or EOF */ &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  if (ferror(fp) || feof(fp)) &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   continue; &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  /* count words in received line */&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  /* Words are defined as separated&lt;br /&gt;
by the characters */ &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  /* \t(tab) \n(newline) , ; : . ! ?&lt;br /&gt;
( ) - and [space] */ &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  p = strtok(buffer,&amp;quot;\t\n,;:.!?()-&lt;br /&gt;
&amp;quot;); &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  while(p)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  { &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   count++; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   p = strtok(NULL,&amp;quot;\t\n,;:.!?()-&lt;br /&gt;
&amp;quot;); &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  } &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; }&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; while(!ferror(fp) &amp;amp;&amp;amp; !feof(fp));&lt;br /&gt;
&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Finished reading. Was it due to&lt;br /&gt;
an error? */ &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; if (ferror(fp))&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; { &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  fputs(&amp;quot;\nERROR: Reading source&lt;br /&gt;
file\n&amp;quot;,stderr); &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  fclose(fp); &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  exit(0); &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; } &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Reading finished due to EOF, quite&lt;br /&gt;
valid so print count */ &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; printf(&amp;quot;\nFile %s contains %ld&lt;br /&gt;
words\n&amp;quot;,argv[1],count); &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; fclose(fp); &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;} &lt;BR&gt;&lt;br /&gt;
&lt;BR&gt;&lt;br /&gt;
&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;I&gt;&lt;B&gt;&lt;FONT FACE=&quot;Arial&quot;&gt;Converting Numbers To And From Strings&lt;br /&gt;
&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;/B&gt;&lt;/I&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;All C compilers provide a facility for&lt;br /&gt;
converting numbers to strings. This being sprintf(). However,&lt;br /&gt;
as happens sprintf() is a multi-purpose function that is therefore&lt;br /&gt;
large and slow. The following function ITOS() accepts two parameters,&lt;br /&gt;
the first being a signed integer and the second being a pointer&lt;br /&gt;
to a character string. It then copies the integer into the memory&lt;br /&gt;
pointed to by the character pointer. As with sprintf() ITOS()&lt;br /&gt;
does not check that the target string is long enough to accept&lt;br /&gt;
the result of the conversion. You should then ensure that the&lt;br /&gt;
target string is long enough. &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;Example function for copying a signed&lt;br /&gt;
integer into a string; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;void ITOS(long x, char *ptr) &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;{ &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Convert a signed decimal integer&lt;br /&gt;
to a string */ &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; long pt[9] = { 100000000, 10000000,&lt;br /&gt;
1000000, 100000, 10000, 1000, 100, 10, 1 }; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int n; &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Check sign */ &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; if (x &amp;lt; 0)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; { &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  *ptr++ = &#39;-&#39;; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  /* Convert x to absolute */ &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  x = 0 - x; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; } &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; for(n = 0; n &amp;lt; 9; n++)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; { &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  if (x &amp;gt; pt[n])&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  { &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   *ptr++ = &#39;0&#39; + x / pt[n]; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   x %= pt[n]; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  } &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; } &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; return; &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;} &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;To convert a string to a floating point&lt;br /&gt;
number, C provides two functions; atof() and strtod(). atof()&lt;br /&gt;
has the prototype; &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; double atof(const char *s); &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;strtod has the prototype; &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; double strtod(const char *s,char **endptr);&lt;br /&gt;
&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;Both functions scan the string and convert&lt;br /&gt;
it as far as they can, until they come across a character they&lt;br /&gt;
don&#39;t understand. The difference between the two functions is&lt;br /&gt;
that if strtod() is passed a character pointer for parameter &#39;endptr&#39;,&lt;br /&gt;
it sets that pointer to the first character in the string that&lt;br /&gt;
terminated the conversion. Because of its better error reporting,&lt;br /&gt;
by way of endptr, strtod() is often preferred to atof(). &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;To convert a string to an integer use&lt;br /&gt;
atoi() that has the prototype; &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int atoi(const char *s); &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;atoi() does not check for an overflow,&lt;br /&gt;
and the results are undefined! &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;atol() is a similar function but returns&lt;br /&gt;
a long. Alternatively, you can use strtol() and stroul() instead&lt;br /&gt;
that have better error checking. &lt;/FONT&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;SCRIPT LANGUAGE=&quot;JavaScript1.1&quot; SRC=&quot;http://bdv.bidvertiser.com/BidVertiser.dbm?pid=356752&amp;bid=1629957&quot; type=&quot;text/javascript&quot;&gt;&lt;/SCRIPT&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/650183537613822215/posts/default/4710993946907441804'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/650183537613822215/posts/default/4710993946907441804'/><link rel='alternate' type='text/html' href='http://c-completereference.blogspot.com/2010/12/strings.html' title='STRINGS'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-650183537613822215.post-7764932189567819199</id><published>2010-12-18T06:11:00.001-08:00</published><updated>2010-12-18T06:11:12.294-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="STRUCTURES"/><title type='text'>STRUCTURES</title><content type='html'>&lt;P&gt;&lt;CENTER&gt;&lt;B&gt;&lt;FONT SIZE=4 FACE=&quot;Arial&quot;&gt;STRUCTURES&lt;BR&gt;&lt;br /&gt;
&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;/B&gt;&lt;/CENTER&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;C provides the means to group together&lt;br /&gt;
variables under one name providing a convenient means of keeping&lt;br /&gt;
related information together and providing a structured approach&lt;br /&gt;
to data.&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;The general form for a structure definition&lt;br /&gt;
is;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;typedef struct&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;{&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; variable_type variable_name;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; variable_type variable_name;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;}&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;structure_name;&lt;BR&gt;&lt;br /&gt;
&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;When accessing data files, with a fixed&lt;br /&gt;
record structure, the use of a structure variable becomes essential.&lt;br /&gt;
The following example shows a record structure for a very simple&lt;br /&gt;
name and address file. It declares a data structure called &#39;data&#39;,&lt;br /&gt;
and comprised of six fields; &#39;name&#39;, &#39;address&#39;, &#39;town&#39;, &#39;county&#39;&lt;br /&gt;
, &#39;post&#39; and &#39;telephone&#39;.&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; typedef struct&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; {&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  char name[30];&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  char address[30];&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  char town[30];&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  char county[30];&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  char post[12];&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  char telephone[15];&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; }&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; data;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;The structure &#39;data&#39; may then be used&lt;br /&gt;
in the program as a variable data type for declaring variables;&lt;br /&gt;
&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; data record;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;Thus declares a variable called &#39;record&#39;&lt;br /&gt;
to be of type &#39;data&#39;.&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;The individual fields of the structure&lt;br /&gt;
variable are accessed by the general form;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; structure_variable.field_name;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;Thus, the name field of the structure&lt;br /&gt;
variable record is accessed with;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; record.name&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;There is no limit to the number of fields&lt;br /&gt;
that may comprise a structure, nor do the fields have to be of&lt;br /&gt;
the same types, for example;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; typedef struct&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; {&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  char name[30];&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  int age;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  char *notes;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; }&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; dp;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;Declares a structure &#39;dp&#39; that is comprised&lt;br /&gt;
of a character array field, an integer field and a character pointer&lt;br /&gt;
field. &lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;A structure variable may be passed as&lt;br /&gt;
a parameter by passing the address of the variable as the parameter&lt;br /&gt;
with the &amp;amp; operator thus;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; func(&amp;amp;my_struct)&lt;BR&gt;&lt;br /&gt;
&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;The following is an example program&lt;br /&gt;
that makes use of a structure to provide the basic access to the&lt;br /&gt;
data in a simple name and address file;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;/* A VERY simple address book written&lt;br /&gt;
in ANSI C */&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;#include &amp;lt;stdio.h&amp;gt;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;#include &amp;lt;stdlib.h&amp;gt;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;#include &amp;lt;io.h&amp;gt;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;#include &amp;lt;string.h&amp;gt;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;#include &amp;lt;fcntl.h&amp;gt;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;#include &amp;lt;sys\stat.h&amp;gt;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;/* num_lines is the number of screen&lt;br /&gt;
display lines */&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;#define num_lines 25&lt;BR&gt;&lt;br /&gt;
&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;typedef struct&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;{&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; char name[30];&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; char address[30];&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; char town[30];&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; char county[30];&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; char post[12];&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; char telephone[15];&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;}&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;data;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;data record;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;int handle;&lt;BR&gt;&lt;br /&gt;
&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;/* Function prototypes */&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;void ADD_REC(void);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;void CLS(void);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;void DISPDATA(void);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;void FATAL(char *);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;void GETDATA(void);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;void MENU(void);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;void OPENDATA(void);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;int SEARCH(void);&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;void CLS()&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;{&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int n;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; for(n = 0; n &amp;lt; num_lines; n++)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  puts(&amp;quot;&amp;quot;);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;}&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;void FATAL(char *error)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;{&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; printf(&amp;quot;\nFATAL ERROR: %s&amp;quot;,error);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; exit(0);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;}&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;void OPENDATA()&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;{&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Check for existence of data file&lt;br /&gt;
and if not create it */&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* otherwise open it for reading/writing&lt;br /&gt;
at end of file */&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; handle = open(&amp;quot;address.dat&amp;quot;,O_RDWR|O_APPEND,S_IWRITE);&lt;br /&gt;
&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; if (handle == -1)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; {&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  handle = open(&amp;quot;address.dat&amp;quot;,O_RDWR|O_CREAT,S_IWRITE);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  if (handle == -1)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   FATAL(&amp;quot;Unable to create data&lt;br /&gt;
file&amp;quot;);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; }&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;}&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;void GETDATA()&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;{&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Get address data from operator */&lt;br /&gt;
&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; CLS();&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; printf(&amp;quot;Name &amp;quot;);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; gets(record.name);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; printf(&amp;quot;\nAddress &amp;quot;);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; gets(record.address);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; printf(&amp;quot;\nTown &amp;quot;);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; gets(record.town);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; printf(&amp;quot;\nCounty &amp;quot;);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; gets(record.county);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; printf(&amp;quot;\nPost Code &amp;quot;);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; gets(record.post);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; printf(&amp;quot;\nTelephone &amp;quot;);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; gets(record.telephone);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;}&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;void DISPDATA()&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;{&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Display address data */&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; char text[5];&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; CLS();&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; printf(&amp;quot;Name %s&amp;quot;,record.name);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; printf(&amp;quot;\nAddress %s&amp;quot;,record.address);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; printf(&amp;quot;\nTown %s&amp;quot;,record.town);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; printf(&amp;quot;\nCounty %s&amp;quot;,record.county);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; printf(&amp;quot;\nPost Code %s&amp;quot;,record.post);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; printf(&amp;quot;\nTelephone %s\n\n&amp;quot;,record.telephone);&lt;br /&gt;
&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; puts(&amp;quot;Press RETURN to continue&amp;quot;);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; gets(text);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;}&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;void ADD_REC()&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;{&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Insert or append a new record to&lt;br /&gt;
the data file */&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int result;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; result = write(handle,&amp;amp;record,sizeof(data));&lt;br /&gt;
&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; if (result == -1)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  FATAL(&amp;quot;Unable to write to data&lt;br /&gt;
file&amp;quot;);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;}&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;int SEARCH()&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;{&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; char text[100];&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int result;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; printf(&amp;quot;Enter data to search for&lt;br /&gt;
&amp;quot;);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; gets(text);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; if (*text == 0)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  return(-1);&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; /* Locate start of file */&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; lseek(handle,0,SEEK_SET);&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; do&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; {&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  /* Read record into memory */&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  result = read(handle,&amp;amp;record,sizeof(data));&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  if (result &amp;gt; 0)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  {&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   /* Scan record for matching data&lt;br /&gt;
*/&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   if (strstr(record.name,text) != NULL)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;    return(1);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   if (strstr(record.address,text) !=&lt;br /&gt;
NULL)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;    return(1);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   if (strstr(record.town,text) != NULL)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;    return(1);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   if (strstr(record.county,text) !=&lt;br /&gt;
NULL)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;    return(1);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   if (strstr(record.post,text) != NULL)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;    return(1);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   if (strstr(record.telephone,text)&lt;br /&gt;
!= NULL)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;    return(1);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  }&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; }&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; while(result &amp;gt; 0);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; return(0);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;}&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;void MENU()&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;{&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int option;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; char text[10];&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; do&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; {&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  CLS();&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  puts(&amp;quot;\n\t\t\tSelect Option&amp;quot;);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  puts(&amp;quot;\n\n\t\t\t1 Add new record&amp;quot;);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  puts(&amp;quot;\n\n\t\t\t2 Search for&lt;br /&gt;
data&amp;quot;);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  puts(&amp;quot;\n\n\t\t\t3 Exit&amp;quot;);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  puts(&amp;quot;\n\n\n\n\n&amp;quot;);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  gets(text);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  option = atoi(text);&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  switch(option)&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  {&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   case 1 : GETDATA();&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;     /* Go to end of file to append&lt;br /&gt;
new record */&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;     lseek(handle,0,SEEK_END);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;     ADD_REC();&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;     break;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   case 2 : if (SEARCH())&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;      DISPDATA();&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;     else&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;     {&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;      puts(&amp;quot;NOT FOUND!&amp;quot;);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;      puts(&amp;quot;Press RETURN to continue&amp;quot;);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;      gets(text);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;     }&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;     break;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;   case 3 : break;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  }&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; }&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; while(option != 3);&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;}&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;void main()&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;{&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; CLS();&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; OPENDATA();&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; MENU();&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;}&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;I&gt;&lt;B&gt;&lt;FONT FACE=&quot;Arial&quot;&gt;Bit Fields&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;/B&gt;&lt;/I&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;C allows the inclusion of variables&lt;br /&gt;
with a size of less than eight bits to be included in structures.&lt;br /&gt;
These variables are known as bit fields, and may be any declared&lt;br /&gt;
size from one bit upwards.&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;The general form for declaring a bit&lt;br /&gt;
field is;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; type name : number_of_bits;&lt;BR&gt;&lt;br /&gt;
&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;For example, to declare a set of status&lt;br /&gt;
flags, each occupying one bit;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;typedef struct&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;{&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; unsigned carry  : 1;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; unsigned zero   : 1;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; unsigned over   : 1;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; unsigned parity : 1;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;} &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;df;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;df flags;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;The variable &#39;flags&#39; then occupies only&lt;br /&gt;
four bits in memory, and yet is comprised of four variables that&lt;br /&gt;
may be accessed like any other structure field.&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;I&gt;&lt;B&gt;&lt;FONT FACE=&quot;Arial&quot;&gt;Uunions&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;/B&gt;&lt;/I&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;Another facility provided by C for efficient&lt;br /&gt;
use of available memory is the union structure. A union structure&lt;br /&gt;
is a collection of variables that all share the same memory storage&lt;br /&gt;
address. As such only one of the variables is ever accessible&lt;br /&gt;
at a time.&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;The general form of a union definition&lt;br /&gt;
is;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; union name&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; {&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  type variable_name;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  type variable_name;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  .&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  .&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  .&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  type variable_name;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; };&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;Thus, to declare a union structure for&lt;br /&gt;
two integer variables;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; union data&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; {&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  int vara;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;  int varb;&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; };&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;and to declare a variable of type &#39;data&#39;;&lt;br /&gt;
&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; data my_var;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;The variable &#39;my_var&#39; is then comprised&lt;br /&gt;
of the two variables &#39;vara&#39; and &#39;varb&#39;  that are accessed like&lt;br /&gt;
with any form of structure, eg;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; my_var.vara = 5;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;Assigns a value of 5 to the variable&lt;br /&gt;
&#39;vara&#39; of union &#39;my_var&#39;.&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;I&gt;&lt;B&gt;&lt;FONT FACE=&quot;Arial&quot;&gt;Enumerations&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;/B&gt;&lt;/I&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;An enumeration assigns ascending integer&lt;br /&gt;
values to a list of symbols. An enumeration declaration takes&lt;br /&gt;
the general form;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; enum name { enumeration list } variable_list;&lt;br /&gt;
&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;Thus to define a symbol list of colours,&lt;br /&gt;
you can say;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;enum COLOURS &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;{&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; BLACK,&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; BLUE,&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; GREEN,&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; CYAN,&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; RED,&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; MAGENTA,&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; BROWN,&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; LIGHTGRAY,&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; DARKGRAY,&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; LIGHTBLUE,&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; LIGHTGREEN,&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; LIGHTCYAN,&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; LIGHTRED,&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; LIGHTMAGENTA,&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; YELLOW,&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; WHITE&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;};&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;Then, the number zero may be referred&lt;br /&gt;
to by the symbol BLACK, the number one by the symbol BLUE, the&lt;br /&gt;
number two by the symbol GREEN and so on.&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;The following program illustrates the&lt;br /&gt;
use of an enumeration list to symbolise integers;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;#include &amp;lt;stdio.h&amp;gt;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;enum COLOURS &lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;{&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; BLACK,&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; BLUE,&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; GREEN,&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; CYAN,&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; RED,&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; MAGENTA,&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; BROWN,&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; LIGHTGRAY,&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; DARKGRAY,&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; LIGHTBLUE,&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; LIGHTGREEN,&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; LIGHTCYAN,&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; LIGHTRED,&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; LIGHTMAGENTA,&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; YELLOW,&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; WHITE&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;};&lt;BR&gt;&lt;br /&gt;
&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;void main()&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt;{&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; int x;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; x = RED;&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; printf(&amp;quot;\nVariable &#39;x&#39; holds %d&amp;quot;,x);&lt;br /&gt;
&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;br /&gt;
&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Arial&quot;&gt; }&lt;BR&gt;&lt;br /&gt;
&lt;/FONT&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;SCRIPT LANGUAGE=&quot;JavaScript1.1&quot; SRC=&quot;http://bdv.bidvertiser.com/BidVertiser.dbm?pid=356752&amp;bid=1629957&quot; type=&quot;text/javascript&quot;&gt;&lt;/SCRIPT&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/650183537613822215/posts/default/7764932189567819199'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/650183537613822215/posts/default/7764932189567819199'/><link rel='alternate' type='text/html' href='http://c-completereference.blogspot.com/2010/12/structures.html' title='STRUCTURES'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry></feed>