<?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-270091469191232126</id><updated>2024-11-01T06:32:25.102-04:00</updated><category term="Intro to Computer Programming"/><category term="C#"/><category term=".Net 4.0"/><category term="Design Pattern"/><category term=".Net"/><category term="Arduino"/><category term="Asus"/><category term="ESP32"/><category term="Exceptions"/><category term="ExpressRecipe"/><category term="Hyper-V"/><category term="Intel vs AMD"/><category term="SQL"/><category term="SQL 08"/><category term="StringBuilder"/><category term="VirtualBox"/><category term="WCF"/><category term="Windows 10"/><category term="blu ray drives"/><category term="comma delimited lists"/><category term="computer build"/><category term="computer cases"/><category term="dynamic factory"/><category term="dynamics"/><category term="factory pattern"/><category term="hard drive"/><category term="indexes"/><category term="inheritance"/><category term="motherboards"/><category term="performance"/><category term="power supply"/><category term="static constructor"/><category term="string.Join"/><category term="strings"/><title type='text'>Randy&#39;s blog</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://rhale78.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/270091469191232126/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://rhale78.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/09185478558704427023</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>25</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-270091469191232126.post-8087337603917396786</id><published>2017-07-24T12:35:00.000-04:00</published><updated>2017-07-24T12:35:29.404-04:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Arduino"/><category scheme="http://www.blogger.com/atom/ns#" term="ESP32"/><category scheme="http://www.blogger.com/atom/ns#" term="Hyper-V"/><category scheme="http://www.blogger.com/atom/ns#" term="VirtualBox"/><category scheme="http://www.blogger.com/atom/ns#" term="Windows 10"/><title type='text'>ESP32 - Trials with setup in Windows 10</title><content type='html'>After hearing about the little micro-controller called the ESP32 (&quot;successor&quot; to the ESP8266), I was finally able to get my hands on an ESP-WROOM32. &amp;nbsp;The specs read like an IoT developer&#39;s dream - multiple ADC, I2C, I2S, DAC, LED output controller, PWM, touch input, Infrared send/receive, Bluetooth, wifi, built in temperature sensor, low power usage, among many others...and the price is relatively cheap and ranges from $10-20.&lt;br /&gt;
&lt;br /&gt;
One complaint I do have for the board is its size in relation to the breadboards - inserting it into a breadboard leaves one row of pins available on one side and none on the other - pretty much have to straddle across two different breadboards to be useful. &amp;nbsp;I&#39;m using Dupont cables as an alternate, which works well.&lt;br /&gt;
&lt;br /&gt;
Getting this thing running in a Windows 10 development environment, well, that&#39;s been the fun part. &amp;nbsp;This is some of the struggles I had and what I had to eventually do to get it working.&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;
Arduino IDE&lt;/h4&gt;
Using the Arduino IDE, setup wasn&#39;t too bad.&lt;br /&gt;
I originally had an older version of the Arduino IDE installed, version 1.6. &amp;nbsp;So I upgraded that to the latest (1.8.3 at the time of this writing) and then followed the instructions on adding the ESP32 board to the Arduino board list. &amp;nbsp;This is not as simple as adding the ESP8266 but still wasn&#39;t bad. &amp;nbsp;I used a page similar to&amp;nbsp;&lt;a href=&quot;http://randomnerdtutorials.com/installing-the-esp32-board-in-arduino-ide-windows-instructions/&quot; target=&quot;_blank&quot;&gt;Installing the esp32 board in arduino ide windows&lt;/a&gt;&amp;nbsp;for the instructions on how to set that up. &amp;nbsp;The WifiScan example worked well. &amp;nbsp;The standard LED blink example did not - according to what I&#39;ve found, it seems the pin # for the onboard LED doesn&#39;t exist for the ESP-WROOM32. &amp;nbsp;I added a normal LED, set the pin, and it worked great.&lt;br /&gt;
&lt;br /&gt;
The problem with coding with the Arduino IDE is it&#39;s a bit limited, especially when it comes to the ESP32. &amp;nbsp;There are very few libraries out for the ESP32, so that eliminates most of the advanced features of this controller. &amp;nbsp;Bluetooth, DAC, etc cannot be easily programmed within the environment. &amp;nbsp;Wifi works as well as input/output of the pins - all the stuff you can do with the ESP8266. &amp;nbsp;Most everyone online mentioned using the ESP-IDF.&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;
ESP-IDF in Windows&lt;/h4&gt;
Following the various online how to&#39;s on how to set up the Windows environment for using ESP-IDF, including installing MSYS32 (which is basically an embedded Linux like environment btw) did not go well at all. &amp;nbsp;Eventually gave up on it. &amp;nbsp;The use of an embedded pre-setup Linux environment was kinda a big hint that setup is not easy on Windows. &lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;
Ubuntu - HyperV&lt;/h4&gt;
Since I&#39;m running Windows 10 and already had HyperV setup, I tried running Ubuntu 14 in Hyper-V. &amp;nbsp;In general, setup went well but I noticed it was awfully slow. &amp;nbsp;Played around with the settings and found that RemoteFX greatly improved performance of Ubuntu...but, one big catch - I was stuck at 800x600 resolution max. &amp;nbsp;After doing some searching online, people had mentioned to edit one of the files and force a resolution - which did not work. &amp;nbsp;Another mentioned to not use RemoteFX for Ubuntu - well, that worked but now performance wise it was unusable. &amp;nbsp;So, next to try is VirtualBox.&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;
Windows 10 HyperV and VirtualBox&lt;/h4&gt;
Found out the hard way a year ago that HyperV and VirtualBox do not play nice together on my main PC - start up a VM on either and the host machine reboots without warning. &amp;nbsp;So, had to uninstall HyperV and then install VirtualBox.&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;
Ubuntu - VirtualBox&lt;/h4&gt;
Ubuntu installed extremely quickly in VirtualBox and performance was also very good so I continued to go down this route. &amp;nbsp;I set it up myself but a good walk thru on how to do this is at&amp;nbsp;&lt;a href=&quot;http://iot-bits.com/esp32/getting-started-with-esp32-esp-idf-part-1/&quot;&gt;http://iot-bits.com/esp32/getting-started-with-esp32-esp-idf-part-1/&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;
USB to serial port issues Ubuntu&lt;/h4&gt;
The ESP32 worked great in Windows and was at virtual Com3. &amp;nbsp;In Ubuntu, finding which port and getting it setup to work has been a pain. &amp;nbsp;The ESP-WROOM32 has a built in USB to serial converter (if it was a true serial device I do not believe this would be as difficult). &amp;nbsp;By default, USB pass thru is turned off in VirtualBox - change USB settings with the VM off. That was the easy part. &amp;nbsp;Tell the VM to use Silicon Labs C2102 device and my KVM switches devices to a completely different computer or I lose keyboard/mouse entirely on my main machine and have to forcibly reboot (disconnecting/reconnecting does not work).&lt;br /&gt;
&lt;br /&gt;
Outside of those issues, when I do finally see a USB device on the /dev/tty path (in my case, /dev/ttyUSB0), try to connect to it in Putty and I get a dreaded &quot;Unable to open serial port&quot; - ok, is this a &quot;port is not working&quot; or something else? &amp;nbsp;After doing more digging, it seems this may be a &lt;a href=&quot;https://websistent.com/fix-serial-port-permission-denied-errors-linux/&quot; target=&quot;_blank&quot;&gt;permissions issue&lt;/a&gt;, not a com port not working type issue. &amp;nbsp;After doing an &quot;ls -l /dev/ttyUSB0&quot; command, I find this is probably the issue. &amp;nbsp;Following the direction from Jesin&#39;s blog, I added myself to the dialout group and this seemed to fix the issue. &amp;nbsp;Just remember to log out or the changes do not happen.&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;
ESP-IDF Setup and test in Ubuntu&lt;/h4&gt;
For setup for the toolset, I used&amp;nbsp;&lt;a href=&quot;http://iot-bits.com/esp32/getting-started-with-esp32-esp-idf-part-2/&quot;&gt;http://iot-bits.com/esp32/getting-started-with-esp32-esp-idf-part-2/&lt;/a&gt; - had no issues with this setup.&lt;br /&gt;
&lt;br /&gt;
For the IDF, I used part 3 of their tutorial, which also works great up to the point of their examples. &amp;nbsp;The most recent version of the IDF (v2) moves &quot;HelloWorld&quot; and &quot;Blink&quot; to a &quot;get-started&quot; directory - you won&#39;t see them under examples as the tutorial states. &amp;nbsp;The link to part 3 is&amp;nbsp;&lt;a href=&quot;http://iot-bits.com/esp32/getting-started-with-esp32-esp-idf-part-3/&quot;&gt;http://iot-bits.com/esp32/getting-started-with-esp32-esp-idf-part-3/&lt;/a&gt;. &amp;nbsp;For my setup, I did not have to install the flash utility (&quot;make flash&quot; worked just fine) - just remember to not have anything else open (Arduino IDE, Putty, etc) that could already have the port open.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://rhale78.blogspot.com/feeds/8087337603917396786/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://rhale78.blogspot.com/2017/07/esp32-trials-with-setup-in-windows-10.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/270091469191232126/posts/default/8087337603917396786'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/270091469191232126/posts/default/8087337603917396786'/><link rel='alternate' type='text/html' href='http://rhale78.blogspot.com/2017/07/esp32-trials-with-setup-in-windows-10.html' title='ESP32 - Trials with setup in Windows 10'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/09185478558704427023</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-270091469191232126.post-8717488911683801467</id><published>2016-11-14T18:29:00.000-05:00</published><updated>2016-11-14T18:29:12.896-05:00</updated><category scheme="http://www.blogger.com/atom/ns#" term=".Net"/><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="Exceptions"/><category scheme="http://www.blogger.com/atom/ns#" term="performance"/><title type='text'>Exceptions and Performance</title><content type='html'>&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;span style=&quot;color: black; font-family: &amp;quot;times new roman&amp;quot; , serif; font-size: 12.0pt;&quot;&gt;First, let me put out this disclaimer - the tests and improvements shown here are a worst case scenario done with &quot;out of bounds&quot; testing. &amp;nbsp;While the tests and solutions here show 4,000x+ performance improvement, this is not a typical real world scenario. &amp;nbsp;The information learned here, though, can help gain significant performance improvements in most typical applications. &amp;nbsp;Don&#39;t expect the results shown here in a normal real world application as there are normally a lot of other factors affecting performance other than just one or two pain points.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;span style=&quot;color: black; font-family: &amp;quot;times new roman&amp;quot; , serif; font-size: 12.0pt;&quot;&gt;In a prior post, I discussed the issues with string equality and how to easily increase performance around those areas. &amp;nbsp;Recently I ran into another problematic&amp;nbsp;problem that seems to plague code - the exception.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;span style=&quot;color: black; font-family: &amp;quot;times new roman&amp;quot; , serif; font-size: 12.0pt;&quot;&gt;Exceptions, in languages such as .Net and Java, are there to let the code know when something has happened the code has not accounted for. &amp;nbsp;This could be something such as an attempt to divide by 0, a file missing, or even a network/database connection lost. &amp;nbsp;Exceptions are good things - they allow the programmer to work around the problem. &amp;nbsp;For instance, with a database connection is lost and an exception happens, the program could attempt to reconnect when it receives the exception. &amp;nbsp;Of course, there&#39;s an exception to this, there are some exceptions that can&#39;t easily be handled in user code, such as out of stack space or out of memory - most languages simply abort the program at the point of these exceptions as it&#39;s normally a sign something seriously went wrong. &amp;nbsp;But, exceptions are generally meant to be handled and accounted for, or, if at all possible, avoided entirely as they&#39;re extremely slow.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;span style=&quot;color: black; font-family: &amp;quot;times new roman&amp;quot; , serif; font-size: 12.0pt;&quot;&gt;How slow? &amp;nbsp;Here&#39;s a&amp;nbsp;comparison&amp;nbsp;of various loops against an exception. &amp;nbsp;For the tests, the tests are executed 5 times with an inner loop that performs a simple calculation 250,000,000 times - yes, I did say 250 million. &amp;nbsp;I used 250 million as the loop count as I&#39;m trying to get to get a baseline of approximately 1 second for the specific tests.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;span style=&quot;color: black; font-family: &amp;quot;times new roman&amp;quot; , serif; font-size: 12.0pt;&quot;&gt;First, though, a walk-thru of the performance test code.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;int&lt;/span&gt;&amp;nbsp;iterations&amp;nbsp;=&amp;nbsp;5;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;int&lt;/span&gt;&amp;nbsp;loopCount&amp;nbsp;=&amp;nbsp;250000000;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Stopwatch&amp;nbsp;sw&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt;&amp;nbsp;Stopwatch();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;int&lt;/span&gt;&amp;nbsp;sum&amp;nbsp;=&amp;nbsp;0;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt;&amp;nbsp;k&amp;nbsp;=&amp;nbsp;0;&amp;nbsp;k&amp;nbsp;&amp;lt;&amp;nbsp;iterations;&amp;nbsp;k++)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;sw.Start();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt;&amp;nbsp;j&amp;nbsp;=&amp;nbsp;0;&amp;nbsp;j&amp;nbsp;&amp;lt;&amp;nbsp;loopCount;&amp;nbsp;j++)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;//code&amp;nbsp;to&amp;nbsp;test&amp;nbsp;goes&amp;nbsp;here&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;sw.Stop();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;System.&lt;span style=&quot;color: #2b91af;&quot;&gt;Console&lt;/span&gt;.Write(sw.ElapsedMilliseconds&amp;nbsp;+&amp;nbsp;&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;&amp;nbsp;&quot;&lt;/span&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;sw.Reset();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;System.&lt;span style=&quot;color: #2b91af;&quot;&gt;Console&lt;/span&gt;.WriteLine();&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
In general, there&#39;s nothing really special about this code. &amp;nbsp;It sets up the variables, creates a stopwatch timer (more on that in a second), and then does the loops, with the stopwatch being stopped and reset at the end. &amp;nbsp;The only interesting thing here is the stopwatch timer.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;span style=&quot;color: black; font-family: &amp;quot;times new roman&amp;quot; , serif; font-size: 12.0pt;&quot;&gt;Date/time calculations, such as those done with DateTime.Now.Millisecond, are notorious&amp;nbsp;for not being very accurate - they can vary and are often off by as much as 100ms (on top of DateTime.Now being fairly slow itself). &amp;nbsp;The calculations we need here need to be more accurate. &amp;nbsp;The Stopwatch timer, which is in the System.Diagnostics namespace, is normally very accurate and often to as low as 1ms. &amp;nbsp;Hence, the stopwatch timer is used here for that reason.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;span style=&quot;color: black; font-family: &amp;quot;times new roman&amp;quot; , serif; font-size: 12.0pt;&quot;&gt;Now, back to the timings.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;span style=&quot;color: black; font-family: &amp;quot;times new roman&amp;quot; , serif; font-size: 12.0pt;&quot;&gt;The simplest case is an empty loop that does nothing. &amp;nbsp;The results,&amp;nbsp;for an empty loop, are around 754ms to do the entire loop 250 million times. &amp;nbsp;The exact times I received were:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;785 742 769 748 727&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;span style=&quot;color: black; font-family: &amp;quot;times new roman&amp;quot; , serif; font-size: 12.0pt;&quot;&gt;Next, let&#39;s see what affect a simple calculation will have on this timing. &amp;nbsp;To help prevent the compiler from possibly optimizing the calculation away, we&#39;ll put a variable named sum (shown above) on the outside of the loop and print out the calculation of the summation of j*k, through the entire loop, at the end of the loops. &amp;nbsp;Here&#39;s the code for this simple calculation.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;sum&amp;nbsp;=&amp;nbsp;0;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt;&amp;nbsp;k&amp;nbsp;=&amp;nbsp;0;&amp;nbsp;k&amp;nbsp;&amp;lt;&amp;nbsp;iterations;&amp;nbsp;k++)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;sw.Start();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt;&amp;nbsp;j&amp;nbsp;=&amp;nbsp;0;&amp;nbsp;j&amp;nbsp;&amp;lt;&amp;nbsp;loopCount;&amp;nbsp;j++)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;sum = sum +&amp;nbsp;j&amp;nbsp;*&amp;nbsp;k;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;sw.Stop();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;System.&lt;span style=&quot;color: #2b91af;&quot;&gt;Console&lt;/span&gt;.Write(sw.ElapsedMilliseconds&amp;nbsp;+&amp;nbsp;&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;&amp;nbsp;&quot;&lt;/span&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;sw.Reset();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;System.&lt;span style=&quot;color: #2b91af;&quot;&gt;Console&lt;/span&gt;.WriteLine();&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;span style=&quot;color: black; font-family: &amp;quot;times new roman&amp;quot; , serif; font-size: 12.0pt;&quot;&gt;The results for this one, as we&#39;d expect, are slightly higher than the loop with no code - average of around 938ms (so we come very close to the 1-second test I intended). &amp;nbsp;The exact results were:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;959 927 911 942 953&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;span style=&quot;color: black; font-family: &amp;quot;times new roman&amp;quot; , serif; font-size: 12.0pt;&quot;&gt;Ok, now let&#39;s see what affect a conditional has on this - we&#39;ll check to see if j (inner loop) is 0, if so, just add k (outer loop) to sum, otherwise do the j*k calculation. &amp;nbsp;The code –&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;sum&amp;nbsp;=&amp;nbsp;0;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt;&amp;nbsp;k&amp;nbsp;=&amp;nbsp;0;&amp;nbsp;k&amp;nbsp;&amp;lt;&amp;nbsp;iterations;&amp;nbsp;k++)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;sw.Start();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt;&amp;nbsp;j&amp;nbsp;=&amp;nbsp;0;&amp;nbsp;j&amp;nbsp;&amp;lt;&amp;nbsp;loopCount;&amp;nbsp;j++)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;if&lt;/span&gt;&amp;nbsp;(j&amp;nbsp;==&amp;nbsp;0)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;sum&amp;nbsp;=&amp;nbsp;sum&amp;nbsp;+&amp;nbsp;k;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;else&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;sum&amp;nbsp;=&amp;nbsp;sum&amp;nbsp;+&amp;nbsp;j&amp;nbsp;*&amp;nbsp;k;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;sw.Stop();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;System.&lt;span style=&quot;color: #2b91af;&quot;&gt;Console&lt;/span&gt;.Write(sw.ElapsedMilliseconds&amp;nbsp;+&amp;nbsp;&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;&amp;nbsp;&quot;&lt;/span&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;sw.Reset();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;System.&lt;span style=&quot;color: #2b91af;&quot;&gt;Console&lt;/span&gt;.WriteLine();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background: white; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;span style=&quot;color: black; font-family: &amp;quot;courier new&amp;quot;; font-size: 12.0pt;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;times new roman&amp;quot; , serif; font-size: 12.0pt;&quot;&gt;For this one, we have roughly 1324ms of time used for this summation. Almost double the empty loop and a little over 300ms than the prior example. &amp;nbsp;Still, 1.3s for 250 million calculations isn&#39;t bad.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background: white; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;span style=&quot;color: black; font-family: &amp;quot;times new roman&amp;quot; , serif; font-size: 12.0pt;&quot;&gt;&lt;br /&gt;
Since we&#39;re on the topic of conditionals, can we get better speed out of the C# conditional operator (?:)? &amp;nbsp;The code technically should be roughly equivalent to the code above when it converts to IL. &amp;nbsp;So, for this code:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background: white; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;sum&amp;nbsp;=&amp;nbsp;0;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt;&amp;nbsp;k&amp;nbsp;=&amp;nbsp;0;&amp;nbsp;k&amp;nbsp;&amp;lt; iterations;&amp;nbsp;k++)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;sw.Start();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt;&amp;nbsp;j&amp;nbsp;=&amp;nbsp;0;&amp;nbsp;j&amp;nbsp;&amp;lt;&amp;nbsp;loopCount;&amp;nbsp;j++)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;sum&amp;nbsp;=&amp;nbsp;sum&amp;nbsp;+&amp;nbsp;((j&amp;nbsp;==&amp;nbsp;0)&amp;nbsp;?&amp;nbsp;k&amp;nbsp;:&amp;nbsp;j&amp;nbsp;*&amp;nbsp;k);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;sw.Stop();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;System.&lt;span style=&quot;color: #2b91af;&quot;&gt;Console&lt;/span&gt;.Write(sw.ElapsedMilliseconds&amp;nbsp;+&amp;nbsp;&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;&amp;nbsp;&quot;&lt;/span&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;sw.Reset();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;System.&lt;span style=&quot;color: #2b91af;&quot;&gt;Console&lt;/span&gt;.WriteLine();&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;span style=&quot;color: black; font-family: &amp;quot;times new roman&amp;quot; , serif; font-size: 12.0pt;&quot;&gt;The results are a bit surprising:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;2308 2245 2286 2274 2317&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;span style=&quot;color: black; font-family: &amp;quot;times new roman&amp;quot; , serif; font-size: 12.0pt;&quot;&gt;Wait! What? Why? Why is the code above twice as slow as the &quot;equivalent&quot; inline code? Good question but that&#39;s one to investigate at a different time since the goal of this comparison is exceptions. The hint on this, though, is to look at the IL that&#39;s generated between the two conditional methods. [but, oh, you thought that using the newest way of doing things makes it better and more condensed? Uh, nope - can&#39;t assume anything like that - using this is almost twice as slow as the verbose code in these circumstances].&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;span style=&quot;color: black; font-family: &amp;quot;times new roman&amp;quot; , serif; font-size: 12.0pt;&quot;&gt;Ok, so now we have our baseline, some simple code, and two ways of doing conditions. Now, to the meat of the matter - how bad is the exception? Let&#39;s try with throwing an exception within a try/catch block. The catch block does nothing mainly for the sake of trying to get accurate timing of the performance test.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; sum=0;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt;&amp;nbsp;k&amp;nbsp;=&amp;nbsp;0;&amp;nbsp;k&amp;nbsp;&amp;lt;&amp;nbsp;iterations;&amp;nbsp;k++)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;sw.Start();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt;&amp;nbsp;j&amp;nbsp;=&amp;nbsp;0;&amp;nbsp;j&amp;nbsp;&amp;lt;&amp;nbsp;loopCount/2000000;&amp;nbsp;j++)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;try&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;throw&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #2b91af;&quot;&gt;Exception&lt;/span&gt;();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;catch&lt;/span&gt;(&lt;span style=&quot;color: #2b91af;&quot;&gt;Exception&lt;/span&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;sw.Stop();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;System.&lt;span style=&quot;color: #2b91af;&quot;&gt;Console&lt;/span&gt;.Write(sw.ElapsedMilliseconds&amp;nbsp;+&amp;nbsp;&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;&amp;nbsp;&quot;&lt;/span&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;sw.Reset();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;System.&lt;span style=&quot;color: #2b91af;&quot;&gt;Console&lt;/span&gt;.WriteLine();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;span style=&quot;color: black; font-family: &amp;quot;times new roman&amp;quot; , serif; font-size: 12.0pt;&quot;&gt;The results average out to be 1382ms - oh, so just slightly above the one for the conditional then, right? &amp;nbsp;So, why am I even writing this blog to complain about something that&#39;s not a problem? &amp;nbsp;Well, look closely at the inner loop - look at the count - loopCount (250 million) DIVIDED BY 2,000,000...yes, a for loop that counts from 0 up to 250,000,000/2,000,000, which means it counts up to 125! &amp;nbsp;Yes, 125...not 100,000, just 125...so 1382ms average for just 125 exceptions! &amp;nbsp;That&#39;s roughly 10ms each exception! &amp;nbsp;Nah, exceptions aren&#39;t really a problem, they&#39;re a disaster! &amp;nbsp;The exact times I received for this run were:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;1801 1269 1248 1245 1351&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;span style=&quot;color: black; font-family: &amp;quot;times new roman&amp;quot; , serif; font-size: 12.0pt;&quot;&gt;And, yes, 1801 seems a bit of an outlier but really it&#39;s right in line with the others at taking 14ms vs 10ms. &amp;nbsp;Either way, it&#39;s over 1 second for just 125 exceptions.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;span style=&quot;color: black; font-family: &amp;quot;times new roman&amp;quot; , serif; font-size: 12.0pt;&quot;&gt;Now, I&#39;m doing these tests in debug mode and with any CPU as the configuration. &amp;nbsp;I&#39;m also running these tests within the IDE and with Intelitrace off (Intelitrace only makes things worse, with the worst hit coming to the exceptions test - up to a 3x further performance drop). &amp;nbsp;So, can we get better results when run in x86, x64 or in release modes? &amp;nbsp;Well, let&#39;s try:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; mso-bidi-font-size: 10.0pt;&quot;&gt;Debug - x86&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; mso-bidi-font-size: 10.0pt;&quot;&gt;***Empty loop***&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; mso-bidi-font-size: 10.0pt;&quot;&gt;803 844 770 767 769&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; mso-bidi-font-size: 10.0pt;&quot;&gt;***Simple calculation***&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; mso-bidi-font-size: 10.0pt;&quot;&gt;901 900 899 903 905&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; mso-bidi-font-size: 10.0pt;&quot;&gt;***If conditional with simple calculation***&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; mso-bidi-font-size: 10.0pt;&quot;&gt;1248 1241 1241 1234 1234&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; mso-bidi-font-size: 10.0pt;&quot;&gt;***Conditional operator with simple calculation***&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; mso-bidi-font-size: 10.0pt;&quot;&gt;2215 2185 2196 2207 2206&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; mso-bidi-font-size: 10.0pt;&quot;&gt;***Exceptions (scaled down by 2,000,000)***&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; mso-bidi-font-size: 10.0pt;&quot;&gt;1100 1075 1070 1101 1086&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; mso-bidi-font-size: 10.0pt;&quot;&gt;Debug - x64&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; mso-bidi-font-size: 10.0pt;&quot;&gt;***Empty loop***&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; mso-bidi-font-size: 10.0pt;&quot;&gt;845 844 818 802 818&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; mso-bidi-font-size: 10.0pt;&quot;&gt;***Simple calculation***&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; mso-bidi-font-size: 10.0pt;&quot;&gt;1021 1021 1014 1023 1008&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; mso-bidi-font-size: 10.0pt;&quot;&gt;***If conditional with simple calculation***&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; mso-bidi-font-size: 10.0pt;&quot;&gt;1315 1320 1364 1371 1364&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; mso-bidi-font-size: 10.0pt;&quot;&gt;***Conditional operator with simple calculation***&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; mso-bidi-font-size: 10.0pt;&quot;&gt;2247 2204 2189 2211 2208&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; mso-bidi-font-size: 10.0pt;&quot;&gt;***Exceptions&amp;nbsp;(scaled down by 2,000,000)***&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; mso-bidi-font-size: 10.0pt;&quot;&gt;2760 2922 2785 2807 2793&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; mso-bidi-font-size: 10.0pt;&quot;&gt;Release - Any CPU&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; mso-bidi-font-size: 10.0pt;&quot;&gt;***Empty loop***&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; mso-bidi-font-size: 10.0pt;&quot;&gt;136 145 138 131 132&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; mso-bidi-font-size: 10.0pt;&quot;&gt;***Simple calculation***&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; mso-bidi-font-size: 10.0pt;&quot;&gt;131 132 134 134 150&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; mso-bidi-font-size: 10.0pt;&quot;&gt;***If conditional with simple calculation***&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; mso-bidi-font-size: 10.0pt;&quot;&gt;277 266 270 271 271&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; mso-bidi-font-size: 10.0pt;&quot;&gt;***Conditional operator with simple calculation***&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; mso-bidi-font-size: 10.0pt;&quot;&gt;496 515 495 504 495&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; mso-bidi-font-size: 10.0pt;&quot;&gt;***Exceptions&amp;nbsp;(scaled down by 2,000,000)***&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; mso-bidi-font-size: 10.0pt;&quot;&gt;758 793 762 816 872&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; mso-bidi-font-size: 10.0pt;&quot;&gt;Release - x86&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; mso-bidi-font-size: 10.0pt;&quot;&gt;***Empty loop***&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; mso-bidi-font-size: 10.0pt;&quot;&gt;134 142 146 134 150&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; mso-bidi-font-size: 10.0pt;&quot;&gt;***Simple calculation***&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; mso-bidi-font-size: 10.0pt;&quot;&gt;135 131 133 145 148&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; mso-bidi-font-size: 10.0pt;&quot;&gt;***If conditional with simple calculation***&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; mso-bidi-font-size: 10.0pt;&quot;&gt;267 272 258 269 260&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; mso-bidi-font-size: 10.0pt;&quot;&gt;***Conditional operator with simple calculation***&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; mso-bidi-font-size: 10.0pt;&quot;&gt;500 501 503 500 525&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; mso-bidi-font-size: 10.0pt;&quot;&gt;***Exceptions&amp;nbsp;(scaled down by 2,000,000)***&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; mso-bidi-font-size: 10.0pt;&quot;&gt;794 781 816 811 763&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; mso-bidi-font-size: 10.0pt;&quot;&gt;Release - x64&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; mso-bidi-font-size: 10.0pt;&quot;&gt;***Empty loop***&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; mso-bidi-font-size: 10.0pt;&quot;&gt;240 224 208 204 203&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; mso-bidi-font-size: 10.0pt;&quot;&gt;***Simple calculation***&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; mso-bidi-font-size: 10.0pt;&quot;&gt;235 237 227 222 225&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; mso-bidi-font-size: 10.0pt;&quot;&gt;***If conditional with simple calculation***&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; mso-bidi-font-size: 10.0pt;&quot;&gt;336 332 331 334 339&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; mso-bidi-font-size: 10.0pt;&quot;&gt;***Conditional operator with simple calculation***&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; mso-bidi-font-size: 10.0pt;&quot;&gt;341 360 380 357 356&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; mso-bidi-font-size: 10.0pt;&quot;&gt;***Exceptions&amp;nbsp;(scaled down by 2,000,000)***&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;mso-bidi-font-size: 10.0pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;1885 1883 1988 1973 2031&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;span style=&quot;color: black; font-family: &amp;quot;times new roman&amp;quot; , serif; font-size: 12.0pt;&quot;&gt;Ok, so, in general, if we&#39;re doing release mode and x86, we can get it down quite well, to roughly 6x slower than a simple calculation. &amp;nbsp;Worst case performance seems to be on the x64 with almost a 9x performance drop compared to a simple calculation. &amp;nbsp;Now, remember, the exceptions are actually only executing the loop 125 times compared to 250,000,000 for the others, so, in reality, we&#39;re talking 6x * 2,000,000 or 12 million times worse for the best case and 9x * 2,000,000 or 18 million times for the worst case. Are you having a performance issue in your application, you&#39;re debugging it in the IDE, and the app is throwing a lot of exceptions, and you&#39;re wondering why the app is so slow? &amp;nbsp;Well, to quote a famous Myth Buster - &quot;There&#39;s your problem!&quot; &amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;span style=&quot;color: black; font-family: &amp;quot;times new roman&amp;quot; , serif; font-size: 12.0pt;&quot;&gt;So, in the &quot;real world,&quot; apps are not run in the IDE - they&#39;re started by the OS in various ways (ie command prompt, service/daemon, etc). &amp;nbsp;What affect does the IDE have on exceptions? &amp;nbsp;Well, let&#39;s see...same tests, same code:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;Debug - x86&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;***Empty loop***&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;752 748 746 759 758&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;***Simple calculation***&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;887 890 895 890 883&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;***If conditional with simple calculation***&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;1213 1209 1202 1205 1186&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;***Conditional operator with simple calculation***&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;2162 2241 2164 2155 2162&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;***Exceptions (scaled down by 2,000,000)***&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;2 2 2 2 2&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;span style=&quot;color: black; font-family: &amp;quot;times new roman&amp;quot; , serif; font-size: 12.0pt;&quot;&gt;2ms for exceptions now? &amp;nbsp;The entire loop ran in 2ms? &amp;nbsp;The fun part here is 2ms for just 125 executions of the loop. &amp;nbsp;Let&#39;s drop the scale down a bit and see how it does. &amp;nbsp;For the following runs, I&#39;ve set the scale to be 4,000, so the exceptions loop runs basically 62,500 times and we get the following results for each of the various build configurations. &amp;nbsp;Remember this is outside the IDE (or also via Ctrl-F5 within the IDE).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;Debug - x86&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;***Empty loop***&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;768 758 771 764 752&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;***Simple calculation***&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;888 901 891 889 890&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;***If conditional with simple calculation***&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;1216 1219 1254 1233 1227&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;***Conditional operator with simple calculation***&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;2162 2173 2157 2157 2170&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;***Exceptions (scaled down by 4,000)***&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;1287 1311 1352 1292 1479&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;Debug - x64&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;***Empty loop***&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;820 803 834 793 791&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;***Simple calculation***&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;1010 1018 1026 1014 1042&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;***If conditional with simple calculation***&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;1413 1290 1295 1315 1293&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;***Conditional operator with simple calculation***&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;2237 2235 2270 2314 2277&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;***Exceptions&amp;nbsp;(scaled down by 4,000)***&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;948 949 1011 996 990&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;Release - x86&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;***Empty loop***&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;139 133 135 131 134&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;***Simple calculation***&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;131 131 130 135 132&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;***If conditional with simple calculation***&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;261 260 263 266 263&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;***Conditional operator with simple calculation***&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;504 519 503 514 513&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;***Exceptions&amp;nbsp;(scaled down by 4,000)***&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;1407 1392 1446 1407 1358&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;Release - x64&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;***Empty loop***&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;133 141 134 133 152&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;***Simple calculation***&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;600 602 596 599 604&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;***If conditional with simple calculation***&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;597 603 607 612 592&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;***Conditional operator with simple calculation***&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;599 599 591 599 587&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;***Exceptions&amp;nbsp;(scaled down by 4,000)***&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;885 901 883 855 931&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;span style=&quot;color: black; font-family: &amp;quot;times new roman&amp;quot; , serif; font-size: 12.0pt;&quot;&gt;So, about 500x faster outside the IDE (125x500=62,500). &amp;nbsp;Still, though, at best case we&#39;re talking roughly 4,000x slower than the simple calculation itself... &amp;nbsp;Still, a large enough difference to be a fairly major problem when exceptions are being thrown a lot.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;span style=&quot;color: black; font-family: &amp;quot;times new roman&amp;quot; , serif; font-size: 12.0pt;&quot;&gt;Am I saying we should abandon exceptions? &amp;nbsp;No, not at all (sure, abandon them and go back to what - the &quot;on error gosub&quot; of the VB era?). &amp;nbsp;I am saying that we should use them for what they&#39;re there for - they were designed to give details about a problem that the code did not account for. &amp;nbsp;They should not be used for control flow to break out of methods nor should they be &quot;allowed&quot; to happen &quot;on their own&quot; without code trying to find and avoid the problem first. &amp;nbsp;The simple answer is exceptions are expensive - guard against them to keep them from happening in the first place, where it is possible and where it makes sense. &amp;nbsp;If the code expects a file to exist, verify the file exists before you try to do something with it - don&#39;t assume that because you checked for the file 30 seconds prior that it still exists. &amp;nbsp;Do the checks and guards where it makes sense in the code. &amp;nbsp;If exceptions are extremely rare and should &quot;never&quot; happen, the guard does still cost so use judgment there, but, for things that are possible to happen, definitely try to guard against them to prevent the cost of the exception hit.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;span style=&quot;color: black; font-family: &amp;quot;times new roman&amp;quot; , serif; font-size: 12.0pt;&quot;&gt;Just as an example, let&#39;s try a similar test to above but with a guaranteed failure for a certain percentage of the test. &amp;nbsp;We&#39;ll do a 0-100% fail rate (for space, the results for only 0-10% will be shown) over a smaller loop count of 2,500,000. &amp;nbsp;The code to do the test and avoid the division by zero exception looks like:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background: white; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt;&amp;nbsp;sum&amp;nbsp;=&amp;nbsp;0;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;System.&lt;span style=&quot;color: #2b91af;&quot;&gt;Console&lt;/span&gt;.WriteLine(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;***J/K&amp;nbsp;summation***&quot;&lt;/span&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt;&amp;nbsp;l&amp;nbsp;=&amp;nbsp;0;&amp;nbsp;l&amp;nbsp;&amp;lt;&amp;nbsp;101;&amp;nbsp;l+=1)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;double&lt;/span&gt;&amp;nbsp;remainderValue&amp;nbsp;=&amp;nbsp;loopCount&amp;nbsp;*&amp;nbsp;(1.0&amp;nbsp;-&amp;nbsp;l&amp;nbsp;/&amp;nbsp;100.0);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;double&lt;/span&gt;&amp;nbsp;avg&amp;nbsp;=&amp;nbsp;0.0;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;sum&amp;nbsp;=&amp;nbsp;0;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt;&amp;nbsp;k&amp;nbsp;=&amp;nbsp;0;&amp;nbsp;k&amp;nbsp;&amp;lt;&amp;nbsp;iterations;&amp;nbsp;k++)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;sw.Start();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt;&amp;nbsp;j&amp;nbsp;=&amp;nbsp;0;&amp;nbsp;j&amp;nbsp;&amp;lt;&amp;nbsp;loopCount;&amp;nbsp;j++)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;if&lt;/span&gt;&amp;nbsp;(remainderValue&amp;nbsp;&amp;lt;&amp;nbsp;0 &amp;amp;&amp;amp; (&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt;)remainderValue&amp;nbsp;&amp;gt;j)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;sum&amp;nbsp;=&amp;nbsp;sum&amp;nbsp;+&amp;nbsp;k * j&amp;nbsp;/&amp;nbsp;&lt;span style=&quot;color: #2b91af;&quot;&gt;Math&lt;/span&gt;.Max(0,&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;(&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt;)remainderValue&amp;nbsp;-&amp;nbsp;j);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;else&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;sum&amp;nbsp;=&amp;nbsp;sum&amp;nbsp;+&amp;nbsp;k;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;sw.Stop();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;avg&amp;nbsp;=&amp;nbsp;avg&amp;nbsp;+&amp;nbsp;sw.ElapsedMilliseconds;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;sw.Reset();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;System.&lt;span style=&quot;color: #2b91af;&quot;&gt;Console&lt;/span&gt;.Write(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;&amp;nbsp;&amp;nbsp;&quot; &lt;/span&gt;+ (&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt;)(avg&amp;nbsp;/&amp;nbsp;iterations) + &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&quot;&amp;nbsp;(&quot; + l + &quot;%)&amp;nbsp;&quot;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;System.&lt;span style=&quot;color: #2b91af;&quot;&gt;Console&lt;/span&gt;.WriteLine();&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background: white; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;span style=&quot;color: black; font-family: &amp;quot;times new roman&amp;quot; , serif; font-size: 12.0pt;&quot;&gt;And the code that allows the exceptions to happen looks like:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;System.&lt;/span&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;Console&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.WriteLine(&lt;/span&gt;&quot;***J/K&amp;nbsp;summation&amp;nbsp;w/&amp;nbsp;exceptions***&quot;&lt;span style=&quot;color: black;&quot;&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt;&amp;nbsp;l&amp;nbsp;=&amp;nbsp;0;&amp;nbsp;l&amp;nbsp;&amp;lt;&amp;nbsp;101;&amp;nbsp;l&amp;nbsp;+=&amp;nbsp;1)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;double&lt;/span&gt;&amp;nbsp;remainderValue&amp;nbsp;=&amp;nbsp;loopCount&amp;nbsp;*&amp;nbsp;(1.0&amp;nbsp;-&amp;nbsp;l&amp;nbsp;/&amp;nbsp;100.0);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;double&lt;/span&gt;&amp;nbsp;avg&amp;nbsp;=&amp;nbsp;0.0;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;sum&amp;nbsp;=&amp;nbsp;0;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt;&amp;nbsp;k&amp;nbsp;=&amp;nbsp;0;&amp;nbsp;k&amp;nbsp;&amp;lt;&amp;nbsp;iterations;&amp;nbsp;k++)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;sw.Start();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt;&amp;nbsp;j&amp;nbsp;=&amp;nbsp;0;&amp;nbsp;j&amp;nbsp;&amp;lt;&amp;nbsp;loopCount;&amp;nbsp;j++)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;try&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;sum&amp;nbsp;=&amp;nbsp;sum&amp;nbsp;+&amp;nbsp;k&amp;nbsp;*&amp;nbsp;j&amp;nbsp;/&amp;nbsp;&lt;span style=&quot;color: #2b91af;&quot;&gt;Math&lt;/span&gt;.Max(0,&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;(&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt;)remainderValue&amp;nbsp;-&amp;nbsp;j);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;catch&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp;(&lt;/span&gt;DivideByZeroException&lt;span style=&quot;color: black;&quot;&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;sum&amp;nbsp;=&amp;nbsp;sum&amp;nbsp;+&amp;nbsp;k;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;sw.Stop();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;avg&amp;nbsp;=&amp;nbsp;avg&amp;nbsp;+&amp;nbsp;sw.ElapsedMilliseconds;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;sw.Reset();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;System.&lt;span style=&quot;color: #2b91af;&quot;&gt;Console&lt;/span&gt;.Write(&quot;&amp;nbsp;&amp;nbsp;&quot;&amp;nbsp;+&amp;nbsp;(&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt;)(avg&amp;nbsp;/&amp;nbsp;iterations)&amp;nbsp;+&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&quot;&amp;nbsp;(&quot;&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp;+&amp;nbsp;l&amp;nbsp;+&amp;nbsp;&lt;/span&gt;&quot;%)&amp;nbsp;&quot;&lt;span style=&quot;color: black;&quot;&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;System.&lt;span style=&quot;color: #2b91af;&quot;&gt;Console&lt;/span&gt;.WriteLine();&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;span style=&quot;color: black; font-family: &amp;quot;times new roman&amp;quot; , serif; font-size: 12.0pt;&quot;&gt;The results, not performed in the IDE, for the first 10% without exceptions looks like:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;***J/K summation***&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; 26 (0%) &amp;nbsp; 27 (1%) &amp;nbsp; 25 (2%) &amp;nbsp; 23 (3%) &amp;nbsp; 25 (4%) &amp;nbsp; 24 (5%)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; 25 (6%) &amp;nbsp; 23 (7%) &amp;nbsp; 32 (8%) &amp;nbsp; 29 (9%) &amp;nbsp; 32 (10%)&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;span style=&quot;color: black; font-family: &amp;quot;times new roman&amp;quot; , serif; font-size: 12.0pt;&quot;&gt;And with exceptions, also, not in the IDE, the timing looks like:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;***J/K summation w/ exceptions***&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; 28 (0%) &amp;nbsp;617 (1%) 1227 (2%) 1826 (3%) 2292 (4%) &amp;nbsp;2708 (5%)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Code&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; 3260 (6%) 3787 (7%) 4154 (8%) 5126 (9%) 5412 (10%)&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;span style=&quot;color: black; font-family: &amp;quot;times new roman&amp;quot; , serif; font-size: 12.0pt;&quot;&gt;So, at even 1% of the data failing (25,000 items out of 2,500,000), we&#39;re seeing roughly a 30x drop in performance and at 10% fail rate (250,000 items) we&#39;re seeing over 150x drop in performance - and this drop is already above the &quot;slower performing&quot; code that has the guard clauses in it to prevent the exceptions.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;span style=&quot;color: black; font-family: &amp;quot;times new roman&amp;quot; , serif; font-size: 12.0pt;&quot;&gt;Hopefully, this makes the point fairly clear - exceptions are expensive, even when compared to adding in guard clauses to help prevent them. &amp;nbsp;Even a small frequency of exceptions can cause substantial performance problems in an application so prevent them&amp;nbsp;when you can. &amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;Publishwithline&quot;&gt;
&lt;w:sdt contentlocked=&quot;t&quot; id=&quot;89512093&quot; sdtgroup=&quot;t&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;calibri&amp;quot; , sans-serif; font-size: 1.0pt;&quot;&gt;&lt;w:sdtpr&gt;&lt;/w:sdtpr&gt;&lt;w:sdt docpart=&quot;60C10C42C1964E0D905922F742567D8C&quot; id=&quot;89512082&quot; showingplchdr=&quot;t&quot; storeitemid=&quot;X_5F329CAD-B019-4FA6-9FEF-74898909AD20&quot; text=&quot;t&quot; title=&quot;Post Title&quot; xpath=&quot;/ns0:BlogPostInfo/ns0:PostTitle&quot;&gt;&lt;/w:sdt&gt;&lt;/span&gt;     &lt;/w:sdt&gt;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     &lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://rhale78.blogspot.com/feeds/8717488911683801467/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://rhale78.blogspot.com/2016/11/exceptions-and-performance.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/270091469191232126/posts/default/8717488911683801467'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/270091469191232126/posts/default/8717488911683801467'/><link rel='alternate' type='text/html' href='http://rhale78.blogspot.com/2016/11/exceptions-and-performance.html' title='Exceptions and Performance'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/09185478558704427023</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-270091469191232126.post-7368584617850816085</id><published>2013-07-28T16:52:00.000-04:00</published><updated>2013-09-14T12:11:41.248-04:00</updated><title type='text'>Storage Pools, Dynamic disks, and software RAID experiences</title><content type='html'>A quick disclaimer - I am no where near an expert on Windows Server nor on server equipment. &amp;nbsp;As I have with programming, I&#39;m learning and struggling on my own - best way to learn in my opinion. &amp;nbsp;With that, I know I am not using recommended equipment nor recommended practices so some of this may be my own fault, but, if I&#39;m out there trying to do this, there will be others as well - hopefully this&#39;ll help someone out there or help prevent others from wasting as much time as I have on this... &amp;nbsp;But, as with anything else, your experiences may vary and I am not responsible for any data loss - this is what worked for me and may help or it may not. &lt;br /&gt;
&lt;br /&gt;
As with many of us in the digital age, I have a TON of data that I want to keep and ensure it doesn&#39;t get corrupted or lost thru equipment failure. &amp;nbsp;In my case, this was over 1TB of WinRar files of personal file backups (from files dating back to 1993), 500GB of pics and videos, among some Tivo files, etc. &amp;nbsp;On top of being a digital pack rat, I also hang onto computer equipment and gather equipment as I come across it. &amp;nbsp;So, two of my prior computers were not being used and I had a ton of spare [i.e. not being used] SATA hard drives so I decided to build two file servers from these pieces.&lt;br /&gt;
&lt;br /&gt;
The first system was based on an Intel 975XBX motherboard. &amp;nbsp;Since I planned on loading this thing with SATA drives, I decided to get a cheap server case and my first choice was the Rosewill RSV-L4500 (&lt;a href=&quot;http://www.newegg.com/Product/Product.aspx?Item=N82E16811147164&quot;&gt;http://www.newegg.com/Product/Product.aspx?Item=N82E16811147164&lt;/a&gt;). &amp;nbsp;This case is a beast with 15 internal drive bays. &amp;nbsp;The case worked ok except when the drives failed or when I wanted to upgrade drives - having to open it up, find the failed drive (harder than it sounds with no indicator lights on which drive failed), and replace it along with moving the internal fan bar - anyway, it was a pain to replace drives in this case. &amp;nbsp;Good case, keeps the drives cool, but would be easier with hot swap drive bays. &amp;nbsp;In addition to the motherboard, I added 2 4-port SATA controllers but did not necessarily go after those controllers being RAID - I wanted cheap, with good ratings, with 4 SATA II+ ports. &amp;nbsp;One of the controllers, a Koutech IO-PSA420 (&lt;a href=&quot;http://www.newegg.com/Product/Product.aspx?Item=N82E16816104006&quot;&gt;http://www.newegg.com/Product/Product.aspx?Item=N82E16816104006&lt;/a&gt;) did include RAID support. &amp;nbsp;One of the motherboard&#39;s controllers also supported RAID as well.&lt;br /&gt;
&lt;br /&gt;
The second system was based on an Intel 975XBX2 motherboard (very similar to the prior one). &amp;nbsp;Since I learned the lesson on needing hot swap bays, I went after a similar Rosewill case, the RSV-L4411 (&lt;a href=&quot;http://www.newegg.com/Product/Product.aspx?Item=N82E16811147165&quot;&gt;http://www.newegg.com/Product/Product.aspx?Item=N82E16811147165&lt;/a&gt;). &amp;nbsp;Again, had to get two additional 4-port SATA controllers - same story as before, none were specifically RAID - this time I went after SATA III controllers. &amp;nbsp;I bought two of the Syba SI-PEX40064 controllers (&lt;a href=&quot;http://www.newegg.com/Product/Product.aspx?Item=N82E16816124064&quot;&gt;http://www.newegg.com/Product/Product.aspx?Item=N82E16816124064&lt;/a&gt;). &amp;nbsp;At least one of the controllers on the motherboard included RAID support.&lt;br /&gt;
&lt;br /&gt;
Now, for the drives - the drives ranged from 60GB drives to 1TB sizes, a few being enterprise level drives, some being notebook drives (1TB ones taken out of new systems in favor of 120GB SSDs - yes, they&#39;re that much worth it!). &amp;nbsp;Wide mix of brands and sizes. &amp;nbsp;I had more than enough drives to completely fill both servers - 27 drives total with a total of about 5TB of storage space - all individual drives.&lt;br /&gt;
&lt;br /&gt;
Initially these systems had Windows Server 2012 Essentials loaded on them. &amp;nbsp;While nice and worked (kinda - domain issues with Essentials), I was not fond of the split usage of the drives - a backup share, for instance, was across several drives because the drives didn&#39;t have enough concurrent space to hold the entire folder. &amp;nbsp;I looked at resolutions to this - my first discovery was data deduplication, which is a new feature in Windows Server 2012, but, of course, was not available to Essentials. &amp;nbsp;Data deduplication claimed space savings as high as 75% or higher...so in theory a 1TB drive now becomes a 1.75TB drive? &amp;nbsp;I figured it was worth the upgrade risk...&lt;br /&gt;
&lt;br /&gt;
So, after the upgrade, I noticed the feature of storage spaces, which is also new to Windows Server 2012 (and available in Windows 8). &amp;nbsp;I read up on it and essentially it is a software RAID, but with a bit more control. &amp;nbsp;I took all my individual drives, added them to a mirrored pool, and copied data to the pool. &amp;nbsp;While I had a nice big drive, and it seemed to be fairly safe, my transfer rates were horrible - I&#39;m used to 30-60MB/sec transfer rates and I was getting 10mb or less per second, with often minutes at 0mb/sec.&lt;br /&gt;
After the failed storage spaces attempt, I tried data deduplication, which, in theory, would help on my space issues. &amp;nbsp;I turned it on for several of my larger drives, ran a power shell command to force it to deduplicate the data and I later found I had 300GB extra on that 500GB drive - nice. &amp;nbsp;I tried moving files and a similar problem happened with storage spaces - remove a 50GB file and I get back 50K of space? &amp;nbsp;Yes, data deduplication worked but with that type of recovery after a delete, I needed to combine drives as I was still having the issue of the split share across drives.&lt;br /&gt;
&lt;br /&gt;
So, now, RAID...something I&#39;ve tried before but never had good success with but figured worth a shot again. &amp;nbsp;Since I had few hardware RAID controllers, I figured I&#39;d try software RAID - via Disk Management in Computer Management. &amp;nbsp;Software RAID in Windows is done via dynamic disks - the disks can be spanned (JBOD), striped, mirrored, or RAID 5...there is no option for RAID 6, 10, etc.&lt;br /&gt;
&lt;br /&gt;
On the hot swap server, I set up 2 1TB mirrors (on a pair of WD Green 1TB drives, and a pair of Samsung 1TB laptop drives). &amp;nbsp;I moved all my data from my individual drives onto one of the two mirrors (one for the file backups, the other for the pics, etc). &amp;nbsp;The performance was poor, again with lower than expected transfer rates (this is a mirror so I was expecting some slower). &amp;nbsp;I read that RAID-5 and RAID 10 was a better solution for better performance so I decided to go that route.&lt;br /&gt;
&lt;br /&gt;
After over a day of copying, I set up a software RAID 5 array with 3 500GB hard drives. &amp;nbsp;My thoughts were to put the data there and then switch the 2 software mirrored 1TB&#39;s to RAID 10. &lt;br /&gt;
&lt;br /&gt;
Performance of the RAID 5 was better than the mirror but still pretty sluggish at times (i.e. KB/sec) - but at other times I was able to get 150MB/sec, which is pretty good compared to what I had been seeing. &amp;nbsp;I did not enable data deduplication on these drives as there was a clear warning to not do that on a dynamic volume - if the dedupe database got corrupted, it was possible to lose all data!&lt;br /&gt;
&lt;br /&gt;
Once all the data was copied onto the RAID 5 array, I rebooted and set up the hardware RAID 10 array using the 4 1TB hard drives.&lt;br /&gt;
&lt;br /&gt;
Upon starting up Windows again, the RAID 10 array showed up as a 2TB drive - as expected. &amp;nbsp;I figured I&#39;d get the data off the RAID 5 onto that single logical drive, but, one major problem - the RAID 5 showed as &quot;failed.&quot; &amp;nbsp;The good thing about RAID 5, in theory, is if one drive goes off the array or goes bad, the array can rebuild itself and recover. &amp;nbsp;So, figured I&#39;d reactivate or try to rebuild the array but everything I tried that was suggested on Google and Microsoft, failed. &amp;nbsp;I was not able to get access to the data on the drive or even get the drives to rebuild. &amp;nbsp;I tried switching the drives to a different controller (software RAID and Windows keeps track of the drives that are in the array) but still no luck. &amp;nbsp;I even tried a few suggested software packages that were rated high for recovering data from corrupted RAID 5 volumes and after a week and a half of scanning from products such as Zero Assumption Recovery and ReclaiMe Free RAID Recovery, the most I was able to get valid was 4 50k files and 450MB of very corrupted RAR files. &amp;nbsp;No luck. &lt;br /&gt;
&lt;br /&gt;
Figured I&#39;d pull the RAID 5 drives out, back them up at the sector level, and put them into the other Windows Server to see if I could import the array and get the data that way. &amp;nbsp;During this, I also checked the drives and all were perfectly fine sector wise. &amp;nbsp;But, one of my favorite products for partition/backup of drives, Paragon Hard Disk Manager 12, decided that it would not do a sector backup of any of the drives - never gave a good enough error message to determine why. &amp;nbsp;At this point, I figured I&#39;d already lost the 1TB of data so I was willing to try anything.&lt;br /&gt;
&lt;br /&gt;
I put the failed drives into my other Windows Server and imported the foreign disks. &amp;nbsp;It showed the correct number of drives for the array (3), as expected. &amp;nbsp;I clicked ok and it came up with the size I was expecting as well - about 1TB, but the condition was &quot;data incomplete.&quot; &amp;nbsp;Figured, ok, this may work - except the next error message gave me cause for concern - &quot;some of the volumes you are importing will lose data because you have not moved all your disks to this system. &amp;nbsp;Are you sure you want to continue?&quot; &amp;nbsp;Um - WHAT? I imported all the drives! Can&#39;t do a sector by sector backup and now Windows tells me this. &amp;nbsp;Did some research online and they said this error message was a bug and that it was &quot;safe&quot; to continue. &amp;nbsp;Figured I&#39;d go with the general crowd sourced info and go for it - clicked ok and now I was right back to where I started with the prior server - the entire RAID 5 showing as &quot;failed.&quot; &amp;nbsp;Like on the prior server, tried reactivating the disks (all of which showed as online). &amp;nbsp;Kept getting the &quot;the attempted operation cannot be completed. &amp;nbsp;The selected volume is offline.&quot; &amp;nbsp;I eventually found some documentation on the Window&#39;s diskpart command (a dos version of computer management, which has a bit more capabilities than computer management). &amp;nbsp;The information it showed showed that everything should have been good and that the drive was ready...but, I still could not repair it (it didn&#39;t show it as failed), etc. &lt;br /&gt;
&lt;br /&gt;
Then I came across a similar utility to diskpart that had directory and copy capabilities and was written in C# - all were pluses as I just wanted the data off the drive. &amp;nbsp;The tool is called RAID5Manager and was written by Tal Aloni - (&lt;a href=&quot;http://iknowu.dnsalias.com/files/public/RAID5Manager/Raid5Manager.htm&quot;&gt;http://iknowu.dnsalias.com/files/public/RAID5Manager/Raid5Manager.htm&lt;/a&gt;). &amp;nbsp;I tried the utility and was able to access the array without any issues...and doing a &quot;dir&quot; command, I was able to see directories! &amp;nbsp;Changing to the various directories, I was able to also see the files I expected to see. &amp;nbsp;I figured this was too good to be true so I copied a small file to another drive, opened it up and it worked! &amp;nbsp;Tried a larger RAR file, since RAR has built in consistency checks, and to my surprise WinRar opened the file without complaint! &amp;nbsp;Fun part was the utility only does single copies of files - no wildcards, etc, but, since the utility was written in C#, it wasn&#39;t hard for me to add that myself. &amp;nbsp;After about 5 minutes of code changes, I redeployed the updated utility to the server and did a copy and all files went to the backup drive without any issues. &amp;nbsp;I checked many files and all were in tact! &amp;nbsp;This utility saved me from losing 1TB of backup data to a failed data redundancy RAID 5, that, according to diskpart, was not really failed. &amp;nbsp;Not sure why/how this array got in this state (nor how to get it out except blow it away) but this tool helped recover all the data.&lt;br /&gt;
&lt;br /&gt;
So, lesson learned, while I got &quot;lucky&quot; this time and was able to get my data back, ALWAYS backup data in multiple places - even things such as RAID that should recover data in case of failure will fail - the question is just &quot;when.&quot; &amp;nbsp;In my case, I believe a Windows Server bug bit me hard on this failed RAID 5 volume but no proof either way.&lt;br /&gt;
&lt;br /&gt;
To sum up my experiences:&lt;br /&gt;
1. &amp;nbsp;Storage pools - not a good idea, especially if you&#39;ll be moving files or need performance (i.e. media server). &lt;br /&gt;
2. &amp;nbsp;Dynamic disks - good concept but RAID-5 seems buggy. &amp;nbsp;Performance was ok but not consistent.&lt;br /&gt;
3. &amp;nbsp;Data deduplication - good concept/theory, but do not use on a RAID/dynamic volume! &amp;nbsp;Great returns for data that is rarely used (i.e. backups, archives, etc) but not great for those who move files often (a 50GB file deleted does not mean you get 50GB back - could be very little recovery). &lt;br /&gt;
&lt;br /&gt;
All the suggestions out there always say use hardware RAID, if you need data redundancy, and use RAID compliant drives - which means more money. &lt;br /&gt;
&lt;br /&gt;
Anyway, hope this helps someone out there, especially getting data off a failed dynamic RAID 5 volume that has failed.&lt;br /&gt;
&lt;br /&gt;&lt;!--10mb--&gt;&lt;!--10mb--&gt;&lt;/10mb&gt;</content><link rel='replies' type='application/atom+xml' href='http://rhale78.blogspot.com/feeds/7368584617850816085/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://rhale78.blogspot.com/2013/07/storage-pools-dynamic-disks-and.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/270091469191232126/posts/default/7368584617850816085'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/270091469191232126/posts/default/7368584617850816085'/><link rel='alternate' type='text/html' href='http://rhale78.blogspot.com/2013/07/storage-pools-dynamic-disks-and.html' title='Storage Pools, Dynamic disks, and software RAID experiences'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/09185478558704427023</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-270091469191232126.post-6377106652926146606</id><published>2012-08-30T00:01:00.000-04:00</published><updated>2012-08-31T13:45:27.652-04:00</updated><title type='text'>New PC Build</title><content type='html'>Been a while since I blogged or built a system.  Figured I’d try to get back 
into it again by posting another build entry – this time for my own PC.&lt;br /&gt;
This will be my first “from scratch” build for myself in 7 years (AMD 939 
system was that one), and about 4 years since I bought a couple used mostly-built 
systems (both Intel Core 2 Duos).  Here’s what I decided on to replace all 3 
systems and my thoughts during the build.&amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;First off, the case:&lt;/b&gt;&lt;br /&gt;
I wanted a case that had tons of drive bays, was easy to install 2.5” SSD’s 
and included USB 3.  There were several cases that fit these requirements but 
the Rosewell Blackhawk-Ultra really caught my attention.  The biggest thing that 
grabbed my attention was that 8 fans were already included – and the system had 
capabilities of a total of 15 fans!  I knew my new machine was going to run warm 
so included fans are a big plus as are optional additional fans.  Also liked the 
fact that this case supports motherboards from ATX all the way to HPTX – nice 
feature especially if I wanted to do a dual or quad CPU system in the future.  
Also liked the fact that the power supplies can be mounted on top or on bottom – 
or both (must remove one of the top fans to install on top though).  Overall, 
great case – HUGE and heavy.  TONS of room.  The case is also very well 
built.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Case (&lt;a href=&quot;http://www.newegg.com/Product/Product.aspx?Item=N82E16811147157&amp;amp;Tpk=Rosewell%20Blackhawk-Ultra&quot; target=&quot;_blank&quot;&gt;Rosewell Blackhawk-Ultra&lt;/a&gt;)&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjI-ovofEvFPCgw8Vl3oPhudyVSUI-_kSIFlPNDWFBvN_IErHtq0G8JcTiMoSmnhl-Ge0ALqLD_EnXfzuDyEnfenw7kg5kyeQk7EYsaQAfKMbnqyqVnmV89BN-Tlm_7V_FPj54D53BlPJg/s1600/IMG_20120822_191119.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjI-ovofEvFPCgw8Vl3oPhudyVSUI-_kSIFlPNDWFBvN_IErHtq0G8JcTiMoSmnhl-Ge0ALqLD_EnXfzuDyEnfenw7kg5kyeQk7EYsaQAfKMbnqyqVnmV89BN-Tlm_7V_FPj54D53BlPJg/s320/IMG_20120822_191119.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Clearance after casters added&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhy_K17YTkrnYaaFfp2EiQtAU3dKO8-mTJgKbzfBNWM69mGanuOCBMI72h3aW4tYbrEOErLvekzoENIPRJ142AyluB947JqyWcirFvQMSWzO43cdCRSS3GX4FTz17HvgBX4Jq2l_AnnuMQ/s1600/IMG_20120822_191036.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;br /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEirAkJbgPu0p1-jQPqO8fEm00cvKDJpDBXMvVE_68BjSqCkAsZ-AyqPMKxHcmhAbARhhb8MYJEy1zApKxy2y3myGa8zR5tPZWF-nPGiKQNnMqKachpmhjcani8T-z1wRTIo4IqkEK7GWuk/s1600/IMG_20120822_190831.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEirAkJbgPu0p1-jQPqO8fEm00cvKDJpDBXMvVE_68BjSqCkAsZ-AyqPMKxHcmhAbARhhb8MYJEy1zApKxy2y3myGa8zR5tPZWF-nPGiKQNnMqKachpmhjcani8T-z1wRTIo4IqkEK7GWuk/s320/IMG_20120822_190831.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Bottom of case&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGr860nE4uDR3pG7Gmy5Xxy-ll5DYHxQ6RncYeCI5fNblftb4FrQLvvbF1if6EZwoHNuijuG0a2H9bRHCh7qOh9eJUY-oze19StytvT3zuVBOSb0KoIUNN37YfJP9SrTd40TL9RSNnarg/s1600/IMG_20120822_191000.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGr860nE4uDR3pG7Gmy5Xxy-ll5DYHxQ6RncYeCI5fNblftb4FrQLvvbF1if6EZwoHNuijuG0a2H9bRHCh7qOh9eJUY-oze19StytvT3zuVBOSb0KoIUNN37YfJP9SrTd40TL9RSNnarg/s320/IMG_20120822_191000.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Casters on carpet - just enough clearance to move&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj4_t5_cJwsP9aYzGSDrHYUPLmxwyuEb0lTSLRmZMCfbNTnrITmtbjyeX5FYjb7bf0IcAt0jEyXKv8W_2ukvv1bM88BcN5vMS8Dto-q9yleSTdu6qGhKMot-KcunO6Ele8pccjZ3w4IDaw/s1600/IMG_20120822_200922.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj4_t5_cJwsP9aYzGSDrHYUPLmxwyuEb0lTSLRmZMCfbNTnrITmtbjyeX5FYjb7bf0IcAt0jEyXKv8W_2ukvv1bM88BcN5vMS8Dto-q9yleSTdu6qGhKMot-KcunO6Ele8pccjZ3w4IDaw/s320/IMG_20120822_200922.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;View of Top Control Cables&lt;/td&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj9cqsmEmht_YkRgBxHud2lI-X84kPymiD2v-qHF3r2c1HEz1HJezDjcOJ3cn2JmBP5iC8Sr-aH7_wGi_y3dkTkH26KTtlS_zBcfLHI8uX0ahaWTrzKz5X77Ud5k_iKYTip0xVZ6zZ5NX0/s1600/IMG_20120822_200908.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj9cqsmEmht_YkRgBxHud2lI-X84kPymiD2v-qHF3r2c1HEz1HJezDjcOJ3cn2JmBP5iC8Sr-aH7_wGi_y3dkTkH26KTtlS_zBcfLHI8uX0ahaWTrzKz5X77Ud5k_iKYTip0xVZ6zZ5NX0/s320/IMG_20120822_200908.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;View of Back side of case&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEis2fjSeJuJV93MICmEYhxjKPFKgL0n1lMyU6TgxF9JAL4pP3iY7cCQBV5Ewp3rgoVA8s6zjVe-DlCIQjRG-sppK7T8YhRRAlv6fU1K6rydGRVu2l6rZaUGQDGSWa1CeG7loA2Q8GpMKyA/s1600/IMG_20120822_211552.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEis2fjSeJuJV93MICmEYhxjKPFKgL0n1lMyU6TgxF9JAL4pP3iY7cCQBV5Ewp3rgoVA8s6zjVe-DlCIQjRG-sppK7T8YhRRAlv6fU1K6rydGRVu2l6rZaUGQDGSWa1CeG7loA2Q8GpMKyA/s320/IMG_20120822_211552.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;External Drive &quot;Quick Connect&quot;&lt;/td&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhdyFPUWpw3rJ4UHZzJJaaHVTyHcqavgb-C6JtoWgJkprWVfV86pobT5VNCkGhnJQlOMnNBZiakk7HnHkOeSTEXYwzfbvnYYdvdibjo_KWBAAdHlvY-4rzqyPm_Ke9Dd-UmhyI-fjmBIbY/s1600/IMG_20120823_180823.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhdyFPUWpw3rJ4UHZzJJaaHVTyHcqavgb-C6JtoWgJkprWVfV86pobT5VNCkGhnJQlOMnNBZiakk7HnHkOeSTEXYwzfbvnYYdvdibjo_KWBAAdHlvY-4rzqyPm_Ke9Dd-UmhyI-fjmBIbY/s320/IMG_20120823_180823.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;This thing is huge - just a bit over 2 ft tall and heavy even empty&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;Huge case but not as big 
as I had originally thought.  For some reason I was thinking super tower would 
be a mid-tower (Antec P-180 size) plus the next size down from that in a single 
case – or, in other words a bit over 3ft.  But, this is still pretty big, P-180 
+ the size of the quad drive cage of the P-180…or, a little less than 25” tall 
after casters installed.  This case is also much deeper than the Antec case…so 
it does not easily fit on my desk without hanging off.  This case also sports a 
huge 230mm fan - massive compared to the 120&#39;s I&#39;m used to.  Very quiet fan, 
nothing like I thought it would be.  Low RPM speed as well.&lt;/li&gt;
&lt;li&gt;Two Extended 12v 
power cables included.  Would’ve been nice to include ATX motherboard power 
extension + a full range of extended length SATA/floppy/IDE (ok, scratch that on 
IDE :)) 
cables.  An added plus would’ve been to include a molex to single multi drive 
(i.e. 4+ drive) - SATA cable (i.e. like this one - &lt;a href=&quot;http://www.newegg.com/Product/Product.aspx?Item=N82E16812400127%29%E2%80%A6pipe&quot;&gt;http://www.newegg.com/Product/Product.aspx?Item=N82E16812400127)&lt;/a&gt; .&amp;nbsp; This is a pipe
dream but would’ve been nice.  Doubtful anyone does that, even on a $3k server 
case.&lt;/li&gt;
&lt;li&gt;Fan &quot;hub&quot; - uses one molex to power multiple fans.  There are two of 
these inside the case.  Nice but no control over fan speed, etc.  Added feature 
would be to take the fan PWM signal from the MB and amplify it using one of 
these hubs.  Or, at least a fan controller per hub.&lt;/li&gt;
&lt;li&gt;Side panel can use 230 or 
9 120mm fans.  Yes, 9 120mm fans on side panel!  Power would be a pain.  A hub 
for that would be nice – that is not included!&lt;/li&gt;
&lt;li&gt;230mm fan very quiet but not a 
ton of airflow.&lt;/li&gt;
&lt;li&gt;Casters included.  Can be used without casters and still very 
stable.&lt;/li&gt;
&lt;li&gt;3 positions available for each caster.  Nice to not be restricted to 
a specific position.&lt;/li&gt;
&lt;li&gt;With casters, case is still stable.  Does not add 
excessive height to the case. &lt;/li&gt;
&lt;li&gt;Just enough clearance to clear the carpet 
without dragging (~.5&quot;)&lt;/li&gt;
&lt;li&gt;A plastic parts case for screws would be nice (like 
the Antec P180 series).  Instead these are in a plastic bag, all 
mixed.&lt;/li&gt;
&lt;li&gt;Separated screws would be nice - hard to find some – this is just a 
minor gripe.  So many screws look so similar!  All are pained black which is a 
plus as they match the case very well.&lt;/li&gt;
&lt;li&gt;Manual included but minimal – 
sufficient though.&lt;/li&gt;
&lt;li&gt;Top or bottom (or both) mounted power supply.  If top 
mount, one of the top fans has to be removed.&lt;/li&gt;
&lt;li&gt;All 10 internal drive bays as 
3.5 or 2.5 capable.  Would be nice to include standoffs, even if just paper 
ones, for 2.5” drives.  Would be very nice to have “hot swap” drive 
cages.&lt;/li&gt;
&lt;li&gt;Red LEDs on the visible external fans aren’t too bad- would be nice to 
be able to turn them off.  The blue power LED is pretty bright though.&lt;/li&gt;
&lt;li&gt;Lots 
of pass-thru areas for hiding cables.  Lots of room for small to extremely large 
motherboards.  I think a quad CPU board could easily fit.&lt;/li&gt;
&lt;li&gt;Top-mounted 
controls and cables are more than ample length to reach motherboard.  No 
firewire port on case though.  Not a huge deal but worth noting.&lt;/li&gt;
&lt;li&gt;Cables are 
arranged on the back-plate so no hanging cables by &quot;default.&quot;  These cables go 
to the top-mounted SATA drive mount, and the front-panel controls.&lt;/li&gt;
&lt;li&gt;Fan power 
cables for the front drives were not protected and are easily caught in the back 
panel&#39;s channels – they really need protection or at least attachments or even 
channels to keep them in place without them getting caught&lt;/li&gt;
&lt;li&gt;Stand off tool - 
used to take off standoffs instead of using a wrench/pliers – very nice 
addition.  Manual said 2 were included, only got 1.  Still, one is enough.  
Thought it would be easy to hand loosen the existing standoffs, but had to use a 
screw driver to get them loose.  Configuration was not for a standard ATX board 
but the next larger size.  Easy change and they are labeled but I still put the 
board in the case and verified positions.&lt;/li&gt;
&lt;li&gt;Plenty of screws.  Way too many at 
times due to them not being pre-separated.&lt;/li&gt;
&lt;li&gt;Suggestion from manual is to 
bottom-mount the PS with fan down.  Warning is to keep the bottom dust-filter 
clean or the PS may burn out early.  Agree with what others said on 
Newegg/Amazon.  If we should keep dust out of that area, make the filter 
washable and accessible from the front.  Decided to still go ahead and point PS 
fan down.&lt;/li&gt;
&lt;li&gt;Velcro strap - ???  Can&#39;t be to hold PS in place (not long 
enough).  Had to undo caster to get it unstrapped.  Still unsure of its 
function.&lt;/li&gt;
&lt;li&gt;Bottom of case and where the power supply attaches to the case have 
rubber pads to keep PS vibration down - nice addition.&lt;/li&gt;
&lt;li&gt;Top mounted SATA drive 
port – looks like only designed for 2.5” drives – opening not large enough for 
3.5” drives.  Manual does not state either if this is a SATA II or SATA III 
compatible port.&lt;/li&gt;
&lt;/ol&gt;
&lt;b&gt;Next, the power supply:&lt;/b&gt;&lt;br /&gt;
I wanted a power supply that was modular (to keep air flow going), decent 
efficiency rating, and powerful enough to run an 8-core AMD system.  Did the 
NewEgg power supply calculator and it stated I needed a minimum of 300w power 
supply.  I know from experience that 300w won’t get you much in terms of tons of 
extra hard drives – so I doubled that just to be safe.  Should have plenty of 
additional power if needed.  Currently with the configuration shown here, it 
uses ~150w “normal/idle” use.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Power Supply (&lt;a href=&quot;http://www.amazon.com/gp/product/B0075WFER0/ref=as_li_ss_tl?ie=UTF8&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;creativeASIN=B0075WFER0&amp;amp;linkCode=as2&amp;amp;tag=randsblog-20&quot;&gt;Coolmax ZU-600B&lt;/a&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://www.assoc-amazon.com/e/ir?t=randsblog-20&amp;amp;l=as2&amp;amp;o=1&amp;amp;a=B0075WFER0&quot; style=&quot;border: currentColor !important; margin: 0px !important;&quot; width=&quot;1&quot; /&gt;
)&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgitQKaKveh1vUT9a-5WddvIlzNU8fx2cVJqGJyDQiJbTtcOIwtq9ph0cu9CnbThOWvU6a9rIoGQLUVKpGMZMwc4OT-PYFVmI-nnyzE0PscULqK2e0a_zH47YRZ_aF5-UCpsimj5RnXzuM/s1600/IMG_20120822_193345.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgitQKaKveh1vUT9a-5WddvIlzNU8fx2cVJqGJyDQiJbTtcOIwtq9ph0cu9CnbThOWvU6a9rIoGQLUVKpGMZMwc4OT-PYFVmI-nnyzE0PscULqK2e0a_zH47YRZ_aF5-UCpsimj5RnXzuM/s320/IMG_20120822_193345.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;140mm Fan w/ view of non-modular plugs&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQd0MPP5Vl1KRNV092cFlgk9RLWboZ7NKck9BcYrOzlFvUdK16iF_ajP7D-xG-KdvwXnQJVXMxJkkXcAzJ_WVz2me0on8La2oJZXamqt_zvZ9U8PcO4DcxHmprI7EgWhHlJuRjOsXaaQs/s1600/IMG_20120822_193252.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQd0MPP5Vl1KRNV092cFlgk9RLWboZ7NKck9BcYrOzlFvUdK16iF_ajP7D-xG-KdvwXnQJVXMxJkkXcAzJ_WVz2me0on8La2oJZXamqt_zvZ9U8PcO4DcxHmprI7EgWhHlJuRjOsXaaQs/s320/IMG_20120822_193252.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Modular plugs included&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjG8f8vLbdgFWnohMpVUvU3NFLHmFTDfu04r51kzuuptUL_LMWkTZSuUKnNBShSexB7bN6PVUkGSOgGycKZkGv5_dpKiuWgb3hP3SKktjYBHtwrV_4AtV97trKO-3l4ZWzwuVuyhitDr5s/s1600/IMG_20120822_193357.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjG8f8vLbdgFWnohMpVUvU3NFLHmFTDfu04r51kzuuptUL_LMWkTZSuUKnNBShSexB7bN6PVUkGSOgGycKZkGv5_dpKiuWgb3hP3SKktjYBHtwrV_4AtV97trKO-3l4ZWzwuVuyhitDr5s/s320/IMG_20120822_193357.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;View of modular cable ports&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgONBhgCd1HjH2EhhcGVZy-VOgBUWfDrXB0NU5QzgflmKKvMYXTZF0V57ibsvgv_4yEU4cuVj13T5VLXywZ2nSPRG4wOebRl1wiLIelvyQYKwg3Z4BOMolAH0EVaxtVNbmjx_pMoRtuwDQ/s1600/IMG_20120822_195322.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgONBhgCd1HjH2EhhcGVZy-VOgBUWfDrXB0NU5QzgflmKKvMYXTZF0V57ibsvgv_4yEU4cuVj13T5VLXywZ2nSPRG4wOebRl1wiLIelvyQYKwg3Z4BOMolAH0EVaxtVNbmjx_pMoRtuwDQ/s320/IMG_20120822_195322.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Installed in case&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;600w - more than enough for what I plan 
to run initially.  Extra traditional SATA drives may push it over its limit but 
at ~20w (or less) each, should be plenty even for a full case of drives.  &lt;/li&gt;
&lt;li&gt;This is a partial modular power supply - has cables for almost every system 
now (motherboard power + 4, 2 molex, 2 SATA, 1 8-pin PCI-Express power).  
Modular cables are for 3 extra SATA, 1 6-pin PCI-express (video card), 1 6 or 
8-pin PCI-express (video card), and last modular is for 1 floppy and 3 
additional molex.  Found out the molex connectors aren’t exactly “standard” and 
wouldn’t work with the side fan’s connector.  Molex worked in all other areas 
though.&lt;/li&gt;
&lt;li&gt;Manual is online - not a big deal, just interesting.&lt;/li&gt;
&lt;li&gt;No screws 
included - not big deal.  Case came with plenty.  But, that’s one thing I’ve 
come to expect over the years, even with “cheap” power supplies.&lt;/li&gt;
&lt;li&gt;Power 
supplies and their cables are not designed for cases of this size.  Just due to 
cable length, had to use the molex modular cable just for the fans since one fan 
panel is at top, one is near bottom.&lt;/li&gt;
&lt;li&gt;Routing the power cables takes some 
thought with this case.&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
&lt;b&gt;Have a case and power, now need storage space:&lt;/b&gt;&lt;br /&gt;
Being stuck at SATA II drives (and on the AMD, IDE drives), I wanted to try 
out all the new technology – from SSD to traditional SATA III.  Went with a 
Blu-ray burner as well.&lt;br /&gt;
&lt;b&gt;Drives&lt;/b&gt;&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgRDOi3w0W9moIX8yNUE7jgnlLC82xWDNJmLjytizHkkA_IVD8yCaKo7XoXqGK68UiY5yL3AQYupIepRzro6BdlpTJhnNXwtxUOpioDNywZ-tj1VxoSaqecQz-OywGmlIlbVLNCERoD_0E/s1600/IMG_20120822_205627.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgRDOi3w0W9moIX8yNUE7jgnlLC82xWDNJmLjytizHkkA_IVD8yCaKo7XoXqGK68UiY5yL3AQYupIepRzro6BdlpTJhnNXwtxUOpioDNywZ-tj1VxoSaqecQz-OywGmlIlbVLNCERoD_0E/s320/IMG_20120822_205627.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;All 3 drives installed&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEitgP7X35nn2vaReaVlEaAFbgr5rC2ZF3nP6_FDqJTtUGWr3_fH5oT1zkjNbhgDziGPs6tjQqGHxvZHmMLzWMTkBahvyWekq1IhRBtQZ_02zyhGTkwxmkzmJ1blQcAnVPcrXurl7cI3TBc/s1600/IMG_20120822_202337.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEitgP7X35nn2vaReaVlEaAFbgr5rC2ZF3nP6_FDqJTtUGWr3_fH5oT1zkjNbhgDziGPs6tjQqGHxvZHmMLzWMTkBahvyWekq1IhRBtQZ_02zyhGTkwxmkzmJ1blQcAnVPcrXurl7cI3TBc/s320/IMG_20120822_202337.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Drive tray with 3.5 and 2.5 options&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
Mounted the drives in reverse of what I 
would normally think - power and SATA cables towards the back side of the case.  
A PAIN if you upgrade or add/change drives often to have to remove BOTH front 
and back panels.  Oh well.  Really would be nice to have a RAID-like or hot-swap 
bays.  I did not check to see if the drive cages could be installed “backwards” 
so that you’d only have to take off the back panel when adding/upgrading a 
drive.&lt;br /&gt;
Decided to put a bit of space between the standard drive and the SSDs 
- heat has always been an issue with normal drives...even with the fans, I&#39;m a 
bit cautious.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;SSD (&lt;a href=&quot;http://www.amazon.com/gp/product/B0077CR60Q/ref=as_li_ss_tl?ie=UTF8&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;creativeASIN=B0077CR60Q&amp;amp;linkCode=as2&amp;amp;tag=randsblog-20&quot;&gt;SAMSUNG 830 Series 2.5-Inch 128GB SATA III MLC Internal Solid State Drive (SSD) MZ-7PC128B/WW&lt;/a&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://www.assoc-amazon.com/e/ir?t=randsblog-20&amp;amp;l=as2&amp;amp;o=1&amp;amp;a=B0077CR60Q&quot; style=&quot;border: currentColor !important; margin: 0px !important;&quot; width=&quot;1&quot; /&gt;
)&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3cEGJ8dDg2ljiPEcdABynG10oXJjMKY_SlzZsAlfpjFk9eExyarR3s8SsmcdQuH_SmR9YDR6mGGpBfschvU_yPPK_jwKPAQHGwGsQti_4sD0yTvILgZfugsbTOpq85wSlJpmrPFnaAfI/s1600/IMG_20120822_201202.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3cEGJ8dDg2ljiPEcdABynG10oXJjMKY_SlzZsAlfpjFk9eExyarR3s8SsmcdQuH_SmR9YDR6mGGpBfschvU_yPPK_jwKPAQHGwGsQti_4sD0yTvILgZfugsbTOpq85wSlJpmrPFnaAfI/s320/IMG_20120822_201202.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFGJeq3zfVtcNdZVNyEp2kUj3CY35EpCXySpPjvf3gDwaZU3M9_Brwmxp3f6sHfKPDGDptYzGDDK2Ze0k0Od7GaMENGlT6D4o719CIfXBfdOtllbYMMjKvUFQjBadYSTVLzQwZNB8Hm3E/s1600/IMG_20120822_201145.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFGJeq3zfVtcNdZVNyEp2kUj3CY35EpCXySpPjvf3gDwaZU3M9_Brwmxp3f6sHfKPDGDptYzGDDK2Ze0k0Od7GaMENGlT6D4o719CIfXBfdOtllbYMMjKvUFQjBadYSTVLzQwZNB8Hm3E/s320/IMG_20120822_201145.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUOAx9ECrBhrP1IsFlepBOTmTQfvWWYWkVBCOh9ppWJBB580OrKkzVYAYisSw-rChm4Qr-70YR9b-lzwZk_k2BpXdPsaAd-uMVddhv28qUMtVmQ0zspjvA1rtbi7zcSMlY5nuYN6zL-GM/s1600/IMG_20120822_202140.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUOAx9ECrBhrP1IsFlepBOTmTQfvWWYWkVBCOh9ppWJBB580OrKkzVYAYisSw-rChm4Qr-70YR9b-lzwZk_k2BpXdPsaAd-uMVddhv28qUMtVmQ0zspjvA1rtbi7zcSMlY5nuYN6zL-GM/s320/IMG_20120822_202140.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;Wow, this 
thing is tiny - at first thought it was sample blank Blue-Ray discs.  Totally 
sealed so no exposed circuitry.  Surprised by the 1.5A power requirement (~8w) 
though - seems high.  &lt;/li&gt;
&lt;li&gt;Felt like I was going to break the power connector on both 2.5” drives – 
seems a bit flimsy compared to the 3.5” ones.&lt;/li&gt;
&lt;li&gt;Boy is this drive fast!  Never seen anything this fast!  I was able to 
install Windows 7 Ultimate from DVD to this drive fully in ~13 minutes – with ~2 
minutes of that being from the install wizard itself and human speed.  Like a 
former co-worker told me, I will not want to go back to traditional drives after 
being on this drive!  &lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
&lt;b&gt;Blue-ray (&lt;a href=&quot;http://www.amazon.com/gp/product/B007YWMCA8/ref=as_li_ss_tl?ie=UTF8&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;creativeASIN=B007YWMCA8&amp;amp;linkCode=as2&amp;amp;tag=randsblog-20&quot;&gt;LG Electronics 14x Internal BDXL Blu-Ray Rewriter with Software WH14NS40&lt;/a&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://www.assoc-amazon.com/e/ir?t=randsblog-20&amp;amp;l=as2&amp;amp;o=1&amp;amp;a=B007YWMCA8&quot; style=&quot;border: currentColor !important; margin: 0px !important;&quot; width=&quot;1&quot; /&gt;
)&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiM4xgKPHmP6N8QWnqhG7reX3N2iXpJ8-3tlObgZ8xHsVw1qRhyphenhyphen_zZrXGJMZmQLajwXjsmwJ-KriOH1oisDxZctIrfbsVxmeh_gmbylioONCRseJHl3w9YAMSqAR0qb7X-CQAN5PnoLBUo/s1600/IMG_20120822_201403.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiM4xgKPHmP6N8QWnqhG7reX3N2iXpJ8-3tlObgZ8xHsVw1qRhyphenhyphen_zZrXGJMZmQLajwXjsmwJ-KriOH1oisDxZctIrfbsVxmeh_gmbylioONCRseJHl3w9YAMSqAR0qb7X-CQAN5PnoLBUo/s320/IMG_20120822_201403.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Drive itself&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYeeQWBThBIy0a2gzsY-MAB5sNrRzlAh5qJ5DSxoPWBsGt26Zz_QZ-Wq7WojHDnJ348Jk4ykP0ycYze7kfFoOk-3CZWN3z2bLLc3LfUBxExu43xpm8KItLwMxcsWjmpAeKoBktjfwOftA/s1600/IMG_20120822_211112.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYeeQWBThBIy0a2gzsY-MAB5sNrRzlAh5qJ5DSxoPWBsGt26Zz_QZ-Wq7WojHDnJ348Jk4ykP0ycYze7kfFoOk-3CZWN3z2bLLc3LfUBxExu43xpm8KItLwMxcsWjmpAeKoBktjfwOftA/s320/IMG_20120822_211112.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Exterior faceplate removed - after much coaxing&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&amp;nbsp; &lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNryf_EoqkJeEA9pgkwLmzQBBp1fziObBTNVnS2L6pP7ZzO8_mrWqMHvC_AbekH_tr6fGWGxAoBzgzniPvVTPcCyNeOjHXfz4lkPUGHY0SBvpHSep6yN_VFX2qNMSesvFAQ0o8in1-sHc/s1600/IMG_20120822_211143.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNryf_EoqkJeEA9pgkwLmzQBBp1fziObBTNVnS2L6pP7ZzO8_mrWqMHvC_AbekH_tr6fGWGxAoBzgzniPvVTPcCyNeOjHXfz4lkPUGHY0SBvpHSep6yN_VFX2qNMSesvFAQ0o8in1-sHc/s320/IMG_20120822_211143.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Empty drive bay - no steel plate, thankfully&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEht3U5kp3_3t1IJZsuOu9DhPu0P6vys-2YkuSEC-X6pfVph67j2piN6xZxkg3QpAy6VcUqO3cSVlcmjQUUokOTT08dDayCKw-bzWGNI8rk_daZJyygypme5G6HUSG6pxdcZLQH5OlUVT0c/s1600/IMG_20120822_211530.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEht3U5kp3_3t1IJZsuOu9DhPu0P6vys-2YkuSEC-X6pfVph67j2piN6xZxkg3QpAy6VcUqO3cSVlcmjQUUokOTT08dDayCKw-bzWGNI8rk_daZJyygypme5G6HUSG6pxdcZLQH5OlUVT0c/s320/IMG_20120822_211530.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Installed drive&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;Surprising - no manual, no 
sample disks – it is an OEM so not really expecting it.  SATA cable and Molex to 
SATA power adapter though and software CD/DVD were included. &lt;/li&gt;
&lt;li&gt;One of the 
things I always hate about installing external drives is the plate that normally 
shields that area.  Rosewell was nice for the topmost drive and didn&#39;t install 
the steel plate - but the nice &quot;shield&quot; that covers the hole was a PAIN to get 
out.  I did not remove the front panel of the case (come on, installing one 
drive here, not redoing everything front facing).  Had to take a flat head and 
pliers to get it out after a bit of hammering on it with the flathead.  Not easy 
- had much easier.  Like another reviewer said, that ain&#39;t going back on 
there.&lt;/li&gt;
&lt;li&gt;The &quot;quick install&quot; drive feature on the one side of the case is 
nice – very easy to do...other side, if you want the drive &quot;stable&quot; requires 
screws.  The quick install feature is nice, but, um, I&#39;d rather have this on the 
drives I&#39;ll change often such as the 3.5/2.5&quot; ones - am not going to fight the 
case to do another external drive.  Nice feature but not worth the money 
IMO.&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
&lt;b&gt;Hybrid (&lt;a href=&quot;http://www.amazon.com/gp/product/B003NSBF32/ref=as_li_ss_tl?ie=UTF8&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;creativeASIN=B003NSBF32&amp;amp;linkCode=as2&amp;amp;tag=randsblog-20&quot;&gt;Seagate Momentus XT 500 GB 2.5 Inch Solid State Hybrid Drive ST95005620AS&lt;/a&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://www.assoc-amazon.com/e/ir?t=randsblog-20&amp;amp;l=as2&amp;amp;o=1&amp;amp;a=B003NSBF32&quot; style=&quot;border: currentColor !important; margin: 0px !important;&quot; width=&quot;1&quot; /&gt;
)&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhlB0F6lXTkYerzR4bvfsVzmAm_-HWPsuHwOPsHPcroiGQ-fJXQ-fE4GhItgX7jAXKVzaL2lIIrFmptdF6cocSUqP-RprROElJDBEW9e57f5GfJMINtfewahzbEteXyT59C7b9FlpG3o-E/s1600/IMG_20120822_205007.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhlB0F6lXTkYerzR4bvfsVzmAm_-HWPsuHwOPsHPcroiGQ-fJXQ-fE4GhItgX7jAXKVzaL2lIIrFmptdF6cocSUqP-RprROElJDBEW9e57f5GfJMINtfewahzbEteXyT59C7b9FlpG3o-E/s320/IMG_20120822_205007.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Hybrid drive with paper spacers&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;ol&gt;
&lt;li&gt;Tiny little thing - about 
what I&#39;d expect for a laptop drive (1.8/2.5&quot;). Very nervous about putting this 
in the drive cage as is as there&#39;s very little separation between the exposed 
underside of the circuit board and the metal cage.  Drive really needs a spacer 
of some sort.  But, I guess it&#39;s meant as a laptop drive, not to be put in a 
desktop case.  Found some old paper spacers from the age of the 486&#39;s - put 
those between the cage and the drive to add a micron more space.  Rather not see 
a drive or power supply go up in smoke.  Drive seems to be fine and works 
without issue.  Have not tested speed yet but the hybrid is meant to store 
commonly used files in SSD and the rest on magnetic.  With the SSD being master, 
not going to be easy to test raw performance of that.&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
&lt;b&gt;SATA III (&lt;a href=&quot;http://www.amazon.com/gp/product/B0088PUEPK/ref=as_li_ss_tl?ie=UTF8&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;creativeASIN=B0088PUEPK&amp;amp;linkCode=as2&amp;amp;tag=randsblog-20&quot;&gt;Western Digital 1 TB WD Blue SATA III 7200 RPM 64 MB Cache Bulk/OEM Desktop Hard Drive&lt;/a&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://www.assoc-amazon.com/e/ir?t=randsblog-20&amp;amp;l=as2&amp;amp;o=1&amp;amp;a=B0088PUEPK&quot; style=&quot;border: currentColor !important; margin: 0px !important;&quot; width=&quot;1&quot; /&gt;
)&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgnjKwtYTWSxganqAwuKiOeLzrluVah_Cez3FRpktmU2WAnrZM2lCfxS2ruevcG3tDcyJVZ-LtEZ2BxKRE1tX35EG44QAdC_3zpg19nACVUH2r0fIHWASRyoNo3jhStq9wDMA_Nqf2eYMI/s1600/IMG_20120822_205542.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgnjKwtYTWSxganqAwuKiOeLzrluVah_Cez3FRpktmU2WAnrZM2lCfxS2ruevcG3tDcyJVZ-LtEZ2BxKRE1tX35EG44QAdC_3zpg19nACVUH2r0fIHWASRyoNo3jhStq9wDMA_Nqf2eYMI/s320/IMG_20120822_205542.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;Now this is what I&#39;m used to.  SATA III 1TB 
WD Blue.  Nothing at all new here other than SATA III.  Drive installed 
fine.&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
&lt;b&gt;Cooling:&lt;/b&gt;&lt;br /&gt;
Since I’m running an AMD processor and since it’s also 8-core and meant for 
overclocking, I decided to go water-cooled – also, a first for me.  After 
reading many reviews, decided on the Thermaltake Water2.0 Pro.  So far it’s 
keeping the stock-parameter AMD 8-core, when idle, at 32C – have seen it go as 
high as 48C under load.  Not bad, especially when my Intel Core 2 Duo systems 
were sitting around 55C+.  Prefer to keep temps below 40C – running a computer, 
not a stove :)&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Water cooler (&lt;a href=&quot;http://www.amazon.com/gp/product/B007UIX1M4/ref=as_li_ss_tl?ie=UTF8&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;creativeASIN=B007UIX1M4&amp;amp;linkCode=as2&amp;amp;tag=randsblog-20&quot;&gt;Thermaltake Water 2.0 PRO/All In One Liquid Cooling System CLW0216&lt;/a&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://www.assoc-amazon.com/e/ir?t=randsblog-20&amp;amp;l=as2&amp;amp;o=1&amp;amp;a=B007UIX1M4&quot; style=&quot;border: currentColor !important; margin: 0px !important;&quot; width=&quot;1&quot; /&gt;
)&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjRHkAWooDatJvTae_AuwsG6soLjD_Mj7mi8dzJ-917uLvMfdoUbku0wgGyuqwsIvEh4hTLWoXCmZ3pnV_QBGY_8DmTrLW5lVKmS2FUNlmnAqqKSNIOgQpU12yT2Wc-gmiVbw0dyvpuh7c/s1600/IMG_20120822_212046.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjRHkAWooDatJvTae_AuwsG6soLjD_Mj7mi8dzJ-917uLvMfdoUbku0wgGyuqwsIvEh4hTLWoXCmZ3pnV_QBGY_8DmTrLW5lVKmS2FUNlmnAqqKSNIOgQpU12yT2Wc-gmiVbw0dyvpuh7c/s320/IMG_20120822_212046.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEja7BM6udaLjU4YFJrVi5bHorDlFwa6Dvux-PzRLm-xuwZehsOmMYftyMIgOJPbruzNJCOrV3cgAchyphenhyphennky4Vz53CFmZimC9IsjViXJUnI7i15JL6KY01-UDz9X7vSV3eINzejl2mFkttZY/s1600/IMG_20120822_212335.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEja7BM6udaLjU4YFJrVi5bHorDlFwa6Dvux-PzRLm-xuwZehsOmMYftyMIgOJPbruzNJCOrV3cgAchyphenhyphennky4Vz53CFmZimC9IsjViXJUnI7i15JL6KY01-UDz9X7vSV3eINzejl2mFkttZY/s320/IMG_20120822_212335.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Water cooler radiator and 2 fans&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgyKuIU_mVnl5irJ4z2L6isH2A32L7r0rm_UixlFLASH47FSuYD_tvQ_KCdqnEt4POAIvJqC8YHAoMLNcDZrB8umn_b4qw0Uogu1ViCKkmulU6OwHw_hFFTnoYxh534UAWsJ_ki19pSRpw/s1600/IMG_20120822_212419.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgyKuIU_mVnl5irJ4z2L6isH2A32L7r0rm_UixlFLASH47FSuYD_tvQ_KCdqnEt4POAIvJqC8YHAoMLNcDZrB8umn_b4qw0Uogu1ViCKkmulU6OwHw_hFFTnoYxh534UAWsJ_ki19pSRpw/s320/IMG_20120822_212419.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Parts for Intel or AMD&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjP8S2xSTpXF83_f4l9wVSR6L4R3zD_w7s9Ota3l-EZpPhLDpKTjq5YO99ZuKEixTZHo5BT95XPu-9OVxjARnMx-JyxlPyFJSLXJImFBJvBmri4FPzSToB_L2GShCsA258w1YVzEAssbHI/s1600/IMG_20120822_221939.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjP8S2xSTpXF83_f4l9wVSR6L4R3zD_w7s9Ota3l-EZpPhLDpKTjq5YO99ZuKEixTZHo5BT95XPu-9OVxjARnMx-JyxlPyFJSLXJImFBJvBmri4FPzSToB_L2GShCsA258w1YVzEAssbHI/s320/IMG_20120822_221939.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Pump itself (with installed brackets for AMD) showing thermal paste&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgc-SFE9fLfJFiLi5noK8d-r0iBve4V0B6QcRgnhGPYAC2_NxiHgOL7oivAyean0M35dnbyUD87_o42dlkHJJh8Qz-ZpwVhmi_RLWElCqv3sVihoz8yPpwTpKpjl6HpLrmoWsm3LG-g7tc/s1600/IMG_20120822_220318.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgc-SFE9fLfJFiLi5noK8d-r0iBve4V0B6QcRgnhGPYAC2_NxiHgOL7oivAyean0M35dnbyUD87_o42dlkHJJh8Qz-ZpwVhmi_RLWElCqv3sVihoz8yPpwTpKpjl6HpLrmoWsm3LG-g7tc/s320/IMG_20120822_220318.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Back of Motherboard with installed cooler plate&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&amp;nbsp; &lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhEBYvjQy47Nt18yrY1251Vz6KceD07MNSj_iNOUbJJRT3DXq5gt0sVAEPS5tCLTHmE2BRVKa8Ffp0nygT_414Ja-ofwOgRevRmUpNoijoLe5bSn1l-LEKf-L7jkLymEdLyLQmMRoMvH4A/s1600/IMG_20120822_224431.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhEBYvjQy47Nt18yrY1251Vz6KceD07MNSj_iNOUbJJRT3DXq5gt0sVAEPS5tCLTHmE2BRVKa8Ffp0nygT_414Ja-ofwOgRevRmUpNoijoLe5bSn1l-LEKf-L7jkLymEdLyLQmMRoMvH4A/s320/IMG_20120822_224431.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Water cooler installed&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhnax9OXK1GFtpquzSzGqEcqILwO-ETjrIUuGzklj3-mNp-2rJHZjCsG36zZTNPTVPR0LcT-MKazEIEg62Te5RDSyt3KIC41Ctwo-B0Vdsb61m785OKDrDrOwFL_slEMG1pvpoyBA-5yNQ/s1600/IMG_20120822_225137.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhnax9OXK1GFtpquzSzGqEcqILwO-ETjrIUuGzklj3-mNp-2rJHZjCsG36zZTNPTVPR0LcT-MKazEIEg62Te5RDSyt3KIC41Ctwo-B0Vdsb61m785OKDrDrOwFL_slEMG1pvpoyBA-5yNQ/s320/IMG_20120822_225137.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Another view of water cooler&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGqgivFR0S3TGshDW9RO19KVuFRSld8N7-R70tesWZRN2t9qYmwxJ2gVXWdSnogzGuv1FL9hc2RSuBlIyZ1oZm-nXXlVcnhq9gfOQ4dxDh1oEQ5v-HEL24bX3E3lx_2JAZmwWB-axrn3o/s1600/IMG_20120822_225310.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGqgivFR0S3TGshDW9RO19KVuFRSld8N7-R70tesWZRN2t9qYmwxJ2gVXWdSnogzGuv1FL9hc2RSuBlIyZ1oZm-nXXlVcnhq9gfOQ4dxDh1oEQ5v-HEL24bX3E3lx_2JAZmwWB-axrn3o/s320/IMG_20120822_225310.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Another view - notice the room in this case vs the motherboard&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;About what I expect 
for a after-market/non-stock air cooler.  Misc parts for Intel/AMD, fans, 
radiator (i.e. heatsink), etc.  So far so good...and one plus, no leaks in the 
box [blaming UPS, not mfg&#39;s/NewEgg] :)  A plus - a manual :) &lt;/li&gt;
&lt;li&gt;No thermal 
paste included though it appears to be some on the pump itself.  Time to read 
the manual to make sure.  And, yep, first page of the manual suggests &quot;read this 
manual thoroughly and follow all steps in order&quot;...hmm.  Ok, first off it&#39;s 
install pump – but this is hard to do without a motherboard installed...&lt;/li&gt;
&lt;li&gt;I do 
feel like I&#39;m working on a car with this radiator though.  Not huge, but 
still.&lt;/li&gt;
&lt;li&gt;Instructions are not completely clear for first time water-cooler 
installers - backplate for CPU, does that come off or no?  I voted for yes – and 
it is required to take that off first.  Manual said read carefully and follow 
directions in order and that was one of a few steps they left out.&lt;/li&gt;
&lt;li&gt;After 
getting the cooler installed (pain, btw) [but probably normal for users who&#39;re 
used to doing after-market air coolers - I&#39;m not, been 4 yrs!].  And, yes, the 
thermal paste is on the pump - pretty clearly stated don&#39;t touch it in the 
manual.  I did not add additional thermal paste.&lt;/li&gt;
&lt;li&gt;Cooler is QUIET and so are 
the fans.  Would like a bit more control over the cooler.  Believe the next step 
from ThermalTake has that feature.&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Now for the motherboard, CPU, RAM, and video card, then back to the 
cooler:&lt;/b&gt;&lt;br /&gt;
I really like all of Asus’ products – from their Netbooks to their 
tablets to their motherboards.  Haven’t had a single problems with any Asus 
equipment I own or have built for others.  Great company in terms of quality!  
&lt;br /&gt;
For the motherboard, one requirement I had was Firewire.  Asus has 3 
990-based boards (the 990 chipset was also one of my requirements).  One of my 
requirements was a Firewire port – of which the Sabertooth has and so foes the 
M5A99X EVO.  I liked the 3 PCI-express slots on the Sabertooth&lt;br /&gt;
Motherboard 
(Asus Sabertooth 990FX) and also the thermal radar, military spec components, 
etc.  Extra USB 2 ports was also a nice feature.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Motherboard (&lt;a href=&quot;http://www.amazon.com/gp/product/B00539LU3E/ref=as_li_ss_tl?ie=UTF8&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;creativeASIN=B00539LU3E&amp;amp;linkCode=as2&amp;amp;tag=randsblog-20&quot;&gt;ASUS Sabertooth 990FX TUF Series Motherboard AM3+ DDR3 1800 - 990FX&lt;/a&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://www.assoc-amazon.com/e/ir?t=randsblog-20&amp;amp;l=as2&amp;amp;o=1&amp;amp;a=B00539LU3E&quot; style=&quot;border: currentColor !important; margin: 0px !important;&quot; width=&quot;1&quot; /&gt;
)&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgM6w0Jci8bczKyj5o3hMB3UKwSY51FW5WKHTOyiHl-WIsYnl4kRNxZdYXWIQNT2Z8HkdeSBKfUE6F7YYjfIVakFXg9K7nZF53UP3KZvPEDZAHEuLWC39ZyC1TaVqgR9VbJQVeGkYycXIY/s1600/IMG_20120822_213501.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgM6w0Jci8bczKyj5o3hMB3UKwSY51FW5WKHTOyiHl-WIsYnl4kRNxZdYXWIQNT2Z8HkdeSBKfUE6F7YYjfIVakFXg9K7nZF53UP3KZvPEDZAHEuLWC39ZyC1TaVqgR9VbJQVeGkYycXIY/s320/IMG_20120822_213501.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhT3RB1HoBL2Ub7jzM788k-YYoKd9o44cs2JLdRg_3pmW6Hx2LSgiAF6A_VSArjRmMoi47aio0m_lPM474V766e4HkXGKZHID_NgIf1juLcxDx6Uyrko25vbWr6GzzTKmd8eSChnn9h1Fw/s1600/IMG_20120822_213513.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhT3RB1HoBL2Ub7jzM788k-YYoKd9o44cs2JLdRg_3pmW6Hx2LSgiAF6A_VSArjRmMoi47aio0m_lPM474V766e4HkXGKZHID_NgIf1juLcxDx6Uyrko25vbWr6GzzTKmd8eSChnn9h1Fw/s320/IMG_20120822_213513.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgD8WU3YMusPYpa_c1uoXoQUiGCuEC4kby3yBLZa4CSiMmLJnqQZac1tMLe6JBRlbjzr6o68yU9iB7sY3lb3idVCC6dWcuzmOcrm29WX0g19sOeI4Wuo3KFun4Pt1c-oRKo1fH-VsJB5Dw/s1600/IMG_20120822_214011.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgD8WU3YMusPYpa_c1uoXoQUiGCuEC4kby3yBLZa4CSiMmLJnqQZac1tMLe6JBRlbjzr6o68yU9iB7sY3lb3idVCC6dWcuzmOcrm29WX0g19sOeI4Wuo3KFun4Pt1c-oRKo1fH-VsJB5Dw/s320/IMG_20120822_214011.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEit6cLQq9A90GIvB8I4Gh3GP3SmbboH00nCeBEl-lisWt0wQdZXzXvEMzaF8EHWTKOtzFS_gj0UHjnla8ahPpCpTRCqUUm2-yX0WrtgauZB18P6FxTzkoKlKeV8vT4pJWgp0KGOz3W06rU/s1600/IMG_20120822_213657.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEit6cLQq9A90GIvB8I4Gh3GP3SmbboH00nCeBEl-lisWt0wQdZXzXvEMzaF8EHWTKOtzFS_gj0UHjnla8ahPpCpTRCqUUm2-yX0WrtgauZB18P6FxTzkoKlKeV8vT4pJWgp0KGOz3W06rU/s320/IMG_20120822_213657.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlJ5_lXf4fXWKJ8yIRKguFB_esML6_Hz_gBAH2LDNr5DU-B2rMhZkMihab83UZFWfYLsmIya4bJ0hAgkBpTPfTIkI2kR8CJbIx6gtBlXjWKlyH6tvhs1NBIN_VhTa6PAtoJNSyzZlgW8M/s1600/IMG_20120822_213647.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlJ5_lXf4fXWKJ8yIRKguFB_esML6_Hz_gBAH2LDNr5DU-B2rMhZkMihab83UZFWfYLsmIya4bJ0hAgkBpTPfTIkI2kR8CJbIx6gtBlXjWKlyH6tvhs1NBIN_VhTa6PAtoJNSyzZlgW8M/s320/IMG_20120822_213647.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXLZE3oDEzSfl7MdqrwSOwQPN-RnClXuThlyrNaFDfoyGRyPDMI6aN4Ed9ZgHPQKXjmsdjjdvkSGwhUDuBNSN8mVsqFq2kYBMlevUmTLIjEVhV3T5kmdfPw7yrdWxipJID6QGJte1jcBA/s1600/IMG_20120822_213954.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXLZE3oDEzSfl7MdqrwSOwQPN-RnClXuThlyrNaFDfoyGRyPDMI6aN4Ed9ZgHPQKXjmsdjjdvkSGwhUDuBNSN8mVsqFq2kYBMlevUmTLIjEVhV3T5kmdfPw7yrdWxipJID6QGJte1jcBA/s320/IMG_20120822_213954.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Quick-connect headers&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjy4ymWXqca4TqeK7MJ22zJHP5KafieQzysD4P43LDxcCvnPjF09xCjLgVOG2lHg3-0aRgLa1ubHD-mnMEyIskJIkbU4FC6RnYuXF4SgZkT3zUuCbRfERDcS-EadMhAlMO7B_Cohyy0frA/s1600/IMG_20120822_213637.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjy4ymWXqca4TqeK7MJ22zJHP5KafieQzysD4P43LDxcCvnPjF09xCjLgVOG2lHg3-0aRgLa1ubHD-mnMEyIskJIkbU4FC6RnYuXF4SgZkT3zUuCbRfERDcS-EadMhAlMO7B_Cohyy0frA/s320/IMG_20120822_213637.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;5 year warranty and cert of reliability&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiR-70JOX05vCs8P4o0iMF1tnEMYp9cO5olO9chMnMrP7DZNL3D-XTeLCDJ4Uz1PE4u3WXIkY6ttsctA0_dfycFm7nMjLRnWJVJzrZrg-jF8ER73RaCYBviVu8c1Cob4yvDN6j60uqEZko/s1600/IMG_20120822_213522.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiR-70JOX05vCs8P4o0iMF1tnEMYp9cO5olO9chMnMrP7DZNL3D-XTeLCDJ4Uz1PE4u3WXIkY6ttsctA0_dfycFm7nMjLRnWJVJzrZrg-jF8ER73RaCYBviVu8c1Cob4yvDN6j60uqEZko/s320/IMG_20120822_213522.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgWfLzaLI5Hc5sPn4I8tFtJz9XzeEp84vfYpWg8EzrqHd-BHyODDWqX6VOlq74zdJT6Y2Grapu94rPPQDwLfTbgTzkrFww_ri4RpeSINdPXBgpM4sWRyHaSSkoPb5oemIQBf42Hy1dx63s/s1600/IMG_20120822_213710.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgWfLzaLI5Hc5sPn4I8tFtJz9XzeEp84vfYpWg8EzrqHd-BHyODDWqX6VOlq74zdJT6Y2Grapu94rPPQDwLfTbgTzkrFww_ri4RpeSINdPXBgpM4sWRyHaSSkoPb5oemIQBf42Hy1dx63s/s320/IMG_20120822_213710.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Various components included&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcAMTXb8QEeIS6pNgHqmw07P23MBTEnZc5iCKor_6bHSw6YoxnRb1gNq7t6_UnRCrcbpkpcxjQq6RO-jihV9ZIQL8XYOYlqhPkwcaBSGrk4NgzPEiL6AuZ-fVdPYQnN-zJzdftHXzsjxc/s1600/IMG_20120822_214737.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcAMTXb8QEeIS6pNgHqmw07P23MBTEnZc5iCKor_6bHSw6YoxnRb1gNq7t6_UnRCrcbpkpcxjQq6RO-jihV9ZIQL8XYOYlqhPkwcaBSGrk4NgzPEiL6AuZ-fVdPYQnN-zJzdftHXzsjxc/s320/IMG_20120822_214737.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Wow, tons of room in this case!&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiS0LB7K2x3YcSltFSvrwlh6I5XtJgUhGRDUeYqVzbQba0KkP3BCo_41qRFJgKc-NgbHEmWXQZJpyDkjhhjLlXJdZLBVccO7CoXKzmgHTIMQrhH9Tux6zYRew1CLG-LdxMUh9ga9wozQzo/s1600/IMG_20120822_215453.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiS0LB7K2x3YcSltFSvrwlh6I5XtJgUhGRDUeYqVzbQba0KkP3BCo_41qRFJgKc-NgbHEmWXQZJpyDkjhhjLlXJdZLBVccO7CoXKzmgHTIMQrhH9Tux6zYRew1CLG-LdxMUh9ga9wozQzo/s320/IMG_20120822_215453.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Installed motherboard&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;Motherboard install was pretty standard.  &lt;/li&gt;
&lt;li&gt;Motherboard set inside the case really shows how HUGE this case is.&lt;/li&gt;
&lt;li&gt;Was surprised that only one side of the memory release levers went down – the 
other is fixed and doesn’t move.  New feature to me.&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
&lt;b&gt;CPU (&lt;a href=&quot;http://www.amazon.com/gp/product/B005UBNLFK/ref=as_li_ss_tl?ie=UTF8&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;creativeASIN=B005UBNLFK&amp;amp;linkCode=as2&amp;amp;tag=randsblog-20&quot;&gt;AMD FX-8150 FX 8-Core Black Edition Processor Socket AM3+ - FD8150FRGUBOX&lt;/a&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://www.assoc-amazon.com/e/ir?t=randsblog-20&amp;amp;l=as2&amp;amp;o=1&amp;amp;a=B005UBNLFK&quot; style=&quot;border: currentColor !important; margin: 0px !important;&quot; width=&quot;1&quot; /&gt;
)&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgWkx-Bb5sGZP-rhtSV6g6s9GegB22ZdFtRNHL_-YdfH7GnZDlojXou7Jp5OBKTba7Kg2QwYntX5MZ-aO_ZjjDeoWLe3F9in5IQtJw3q5pgbbhDzZPebl4V03qOljMlDjh-TJ64UjBM-pk/s1600/IMG_20120822_222457.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgWkx-Bb5sGZP-rhtSV6g6s9GegB22ZdFtRNHL_-YdfH7GnZDlojXou7Jp5OBKTba7Kg2QwYntX5MZ-aO_ZjjDeoWLe3F9in5IQtJw3q5pgbbhDzZPebl4V03qOljMlDjh-TJ64UjBM-pk/s320/IMG_20120822_222457.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEir9JSHfHUQohXyZ4j2STnJ_OraMBEXCNvcbzdOtB53WsI-ZRb8-C5g9anYumrZE_mWum0ypXTHgwQz_V9xGqCqzlx5GwGnLKbMowncQkP5xQBn6BnR_q42LnRmp8N-hMox3Bs3z0H3tiw/s1600/IMG_20120822_222519.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEir9JSHfHUQohXyZ4j2STnJ_OraMBEXCNvcbzdOtB53WsI-ZRb8-C5g9anYumrZE_mWum0ypXTHgwQz_V9xGqCqzlx5GwGnLKbMowncQkP5xQBn6BnR_q42LnRmp8N-hMox3Bs3z0H3tiw/s320/IMG_20120822_222519.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjrqVIyrhByS6IGmfytYA5OOjSns-mqs7dGoGu3FkA8H_oTZarnU5qBZdRFHDdePkNrYpGKfsLot2tF-FY-Egr8G3WbJRfaNERnLu7D7Wffrx-n982oTlMa1mDHJfZf4_cGXHhrzaWbYic/s1600/IMG_20120822_222731.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjrqVIyrhByS6IGmfytYA5OOjSns-mqs7dGoGu3FkA8H_oTZarnU5qBZdRFHDdePkNrYpGKfsLot2tF-FY-Egr8G3WbJRfaNERnLu7D7Wffrx-n982oTlMa1mDHJfZf4_cGXHhrzaWbYic/s320/IMG_20120822_222731.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6tFKlBG9eHIhDLU5wyx9vHM0IRSMdSdtf7qkp-2HHCii5AXBhBpHkZ0joD0f0hNjBxhjjsxjdXUMwHJVbRB1sDsvDdWLzK_JWB361cFvywXOSYka5ie72OB2WMj2P61EuMJ8pmytG2iY/s1600/IMG_20120822_222858.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6tFKlBG9eHIhDLU5wyx9vHM0IRSMdSdtf7qkp-2HHCii5AXBhBpHkZ0joD0f0hNjBxhjjsxjdXUMwHJVbRB1sDsvDdWLzK_JWB361cFvywXOSYka5ie72OB2WMj2P61EuMJ8pmytG2iY/s320/IMG_20120822_222858.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;Nice TIN box, not the cardboard ones I&#39;m used to.  Easy 
install - nothing new here.&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
&lt;b&gt;Memory (&lt;a href=&quot;http://www.amazon.com/gp/product/B008VT1N2G/ref=as_li_ss_tl?ie=UTF8&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;creativeASIN=B008VT1N2G&amp;amp;linkCode=as2&amp;amp;tag=randsblog-20&quot;&gt;G.SKILL Ripjaws X Series 32GB (4 x 8GB) 240-Pin SDRAM DDR3 1600 (PC3 12800) Desktop Memory F3-12800CL10Q-32GBXL&lt;/a&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://www.assoc-amazon.com/e/ir?t=randsblog-20&amp;amp;l=as2&amp;amp;o=1&amp;amp;a=B008VT1N2G&quot; style=&quot;border: currentColor !important; margin: 0px !important;&quot; width=&quot;1&quot; /&gt;
)&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;Well, these were a pain - the plastic case was 
difficult to get the chips out.  Got them out but prefer an &quot;easier&quot; container.  
Same old same old here.&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
&lt;b&gt;Video card (&lt;a href=&quot;http://www.amazon.com/gp/product/B005MED9X4/ref=as_li_ss_tl?ie=UTF8&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;creativeASIN=B005MED9X4&amp;amp;linkCode=as2&amp;amp;tag=randsblog-20&quot;&gt;GIGABYTE GV-R667D3-1GI Radeon HD 6670 1GB DDR3 DVI-D / D-Sub / HDMI CrossFire Ready Graphics Card&lt;/a&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://www.assoc-amazon.com/e/ir?t=randsblog-20&amp;amp;l=as2&amp;amp;o=1&amp;amp;a=B005MED9X4&quot; style=&quot;border: currentColor !important; margin: 0px !important;&quot; width=&quot;1&quot; /&gt;
)&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJphxrnfE7jtIfJhmj42qH-Zfxp97CsaQf6KiL2DL1tlM_tTFUNMizfoGrbn62pXFAGJBtTFVq2JL6yKsn1uMqGeZPzUzLHNW0aOqsKjhZMzxmZ_zLnz0n9RjzAE2dZAU_y1I80FHTb90/s1600/IMG_20120822_224926.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJphxrnfE7jtIfJhmj42qH-Zfxp97CsaQf6KiL2DL1tlM_tTFUNMizfoGrbn62pXFAGJBtTFVq2JL6yKsn1uMqGeZPzUzLHNW0aOqsKjhZMzxmZ_zLnz0n9RjzAE2dZAU_y1I80FHTb90/s320/IMG_20120822_224926.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Nice fan/heatsink on video card&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;Video card has a fairly nice heatsink and fan.  The fan is pretty quiet.  
&lt;/li&gt;
&lt;li&gt;Did not see a Crossfire port.  From what I’ve read elsewhere, it uses 
“hyper-crossfire.”&lt;/li&gt;
&lt;li&gt;One HDMI, one SVGA, one DVI port.&lt;/li&gt;
&lt;li&gt;Performance is decent.&lt;/li&gt;
&lt;li&gt;Actually have a 2nd video card coming – nice to have quad monitors and also 
experience crossfire (while it existed on prior builds, I never used it – didn’t 
see the sense as I don’t do a ton of high-performance gaming).&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Final comments on case, water cooler, and power supply:&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;Case and 
PS&lt;/b&gt;&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;Additional comment on the 230mm fan and PS - the molex connector on the PS 
did not fit the molex for the fan - bit of a annoyance.  Had plenty of 
motherboard connectors...but, the side panel fan is now relatively closely tied 
to the case.  Oh well...&lt;/li&gt;
&lt;li&gt;Did think I was going to have a problem with the 
230mm fan and the water cooler - seems to be a good fit after all.  At first 
thought the water cooler was in the way of the fan, but that is not so.&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
&lt;b&gt;Water Cooler&lt;/b&gt;&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;Water cooler radiator as installed is opposite of what the 
book recommends - the tubes were just too close to comfort for me to the power 
regulators (which have heatsinks, which means they will get warm/hot) and the 
bends were a little too tight.  Fits fine with the tubes towards the outside of 
the case. &lt;/li&gt;
&lt;li&gt;Also, did not use the included Y connector - motherboard has 
plenty of fan connectors.  One thing did concern me on the Y - one connector 
looked like it was missing a pin (and wire), the other had all 4 - book did not 
say which fan/pump should go where.  Both fans and pump are on motherboard fan 
connectors.  Cools pretty well as is so leaving alone for now.&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
&lt;b&gt;Conclusion&lt;/b&gt;&lt;br /&gt;
About 4 hrs total to put together but was taking my time and documenting as I went.  Everything 
worked first try.  Win 7 installed in 13 minutes from a DVD.  SSD card is 
handling Win 7, Visual Studio 2010 Ultimate and 2012 Ultimate, Office 2013, and SQL Server 2012.  
Still has plenty of room left.&amp;nbsp; System goes from login screen to ready to use in ~2 seconds.&lt;br /&gt;
So far, it&#39;s extremely difficuly to get the SSD drive to get to100% usage - I can usually easily do this with a traditional drive.&amp;nbsp; Drive rarely gets above 10% usage.&lt;br /&gt;
CPU also stays pretty low - usually around 20% total.&lt;br /&gt;
Motherboard&#39;s BIOS is nice - allows for easy overclocking.&amp;nbsp; I haven&#39;t done so yet.&amp;nbsp; The BIOS has a setting that allows the system to be overclocked into turbo mode, which is 4.2Ghz instead of the 3.6Ghz.&amp;nbsp; Can&#39;t tell the difference either way.&lt;br /&gt;
&lt;br /&gt;
Windows 7 Experience Index with stock settings:&lt;br /&gt;
Processor - 7.7&lt;br /&gt;
Memory - 7.7&lt;br /&gt;
Graphics - 6.8 (overclocked slightly for a 6.9)&lt;br /&gt;
Gaming Graphics - 6.8  (overclocked slightly for a 6.9)&lt;br /&gt;
Hard Drive - 7.9&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;UPDATES&lt;/strong&gt;&lt;br /&gt;
Ordered a second ATI 6670 card with the goal to crossfire the cards and to get a quad-monitor system going.&amp;nbsp; While in the case to add the card, I noticed the power supply itself was fairly warm so I removed the dust filter from the bottom of the case (it is relatively easy to remove - but would be a pain to do more than just a couple times).&amp;nbsp; That should help open up the bottom of the case and allow more air into the power supply.&amp;nbsp; I&#39;d thought about flipping the power supply but the motherboard power cables are already pretty tight - will try it this way first for a while.&lt;br /&gt;
&lt;br /&gt;
Also moved some of the fans to be motherboard-driven instead of off the fan hub.&amp;nbsp; Should allow me to keep better control of the areas that don&#39;t have fans on them (such as the vcore&#39;s).&amp;nbsp; They and the PCI-Express cards seem to run a bit hotter than I&#39;d prefer.&amp;nbsp; So far the moving of the fans to the motherboard along with adjusting the fan speeds seems to have dropped those temps down by 6C.&amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
Unlike what I understood, the ATI 6670 card can not be crossfired as normal cards can (via the bridge) - there is no bridge connector on the cards!&amp;nbsp; From what I&#39;ve read elsewhere, they&#39;re &quot;hyper&quot; crossfired via the PCI-Express bus.&amp;nbsp; The ATI software did allow me to enable crossfire but doing Windows experience testing did not show any improvement so not sure if it didn&#39;t work at all or just not seeing any gain.&amp;nbsp; Even with 2 cards in the system (with crossfire on or off), the video performance stayed at 6.9.&amp;nbsp; Have seen other reports that say the ATI 6670 cards aren&#39;t worth crossfiring as a single 6870 series card is faster than the dual ATI 6670&#39;s would&#39;ve been and is actually cheaper total cost.&amp;nbsp; Not in it for the graphics/gaming so not too concerned about it for now.&amp;nbsp; Little disappointed but, oh well, crossfire is a feature I won&#39;t use much anyway.&amp;nbsp; But, good news is that an additional video card only rose the wattage requirements of the system by 25W idle (from ~125W to ~150W) [as per the reading from my UPS].&amp;nbsp; With all 4 monitors running, total power draw sits around 300W total - course the monitors are adding 150w from the mains, not from the power supply.&amp;nbsp; Really nice to have a quad monitor system and a system that has lower power draw than my prior system.&lt;br /&gt;
&lt;br /&gt;
And the Asus motherboard, well, it seems Asus has relased&lt;a href=&quot;http://usa.asus.com/Motherboards/AMD_AM3Plus/SABERTOOTH_990FX_R20/&quot; target=&quot;_blank&quot;&gt; version 2&lt;/a&gt; of that motherboard with new features.&amp;nbsp; Some neat features (i.e. single button to enter bios, etc) but sure it&#39;s not worth taking apart the entire system, and paying the extra for the newer board.&amp;nbsp; Will stay with what I have.&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://rhale78.blogspot.com/feeds/6377106652926146606/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://rhale78.blogspot.com/2012/08/new-pc-build.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/270091469191232126/posts/default/6377106652926146606'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/270091469191232126/posts/default/6377106652926146606'/><link rel='alternate' type='text/html' href='http://rhale78.blogspot.com/2012/08/new-pc-build.html' title='New PC Build'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/09185478558704427023</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjI-ovofEvFPCgw8Vl3oPhudyVSUI-_kSIFlPNDWFBvN_IErHtq0G8JcTiMoSmnhl-Ge0ALqLD_EnXfzuDyEnfenw7kg5kyeQk7EYsaQAfKMbnqyqVnmV89BN-Tlm_7V_FPj54D53BlPJg/s72-c/IMG_20120822_191119.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-270091469191232126.post-8333658906912853699</id><published>2011-07-23T21:59:00.001-04:00</published><updated>2011-07-23T21:59:36.669-04:00</updated><title type='text'>Trial and Error–WCF Services Part 3 (split to IIS Hosting)</title><content type='html'>&lt;p&gt;After a bit of frustration with the WCF host and client, I decided it would be easier to split the client and service host projects.&amp;nbsp; I did this, relatively easily but now the problem was getting the host to start first and then the client…and having the host start when doing work on the WCF service itself and keeping the client reference updated.&amp;nbsp; Well, simply put, it was going to be a big pain (having 2 VS 2010’s open isn’t bad…but starting up the host every time I wanted to test or make a change would have been).&amp;nbsp; I’ve also been considering having a web host to host these services – and the thing with most hosting providers, they don’t allow Windows services nor console/windows applications (and I wasn’t going to pay $45+/mo to have a hosted virtual server) so my only route was having the service hosting in IIS.&amp;nbsp; Since most providers that allow WCF are running Windows 2008 or 2008 R2, this meant IIS 7 or 7.5, which means it’s compatible with my development environments within Windows 7, thankfully.&lt;/p&gt; &lt;p&gt;So, the client is now in it’s own solution.&amp;nbsp; The client in this case is only for testing – the real client will be in the app.&amp;nbsp; The client is “easy” to create as long as VS 2010 can get a service reference – with the client and host in one solution, that was becoming a pain.&amp;nbsp; With IIS hosting, that pain should go away.&lt;/p&gt; &lt;p&gt;The service solution had a dll that contained the real “service” (the service contract and an implementation of that contract) and a console host.&amp;nbsp; I’ve added a new WCF Windows Service project as described in the blog post (&lt;a href=&quot;http://blog.lyalin.com/2008/04/creating-quick-sample-iis-hosted-wcf.html&quot;&gt;http://blog.lyalin.com/2008/04/creating-quick-sample-iis-hosted-wcf.html&lt;/a&gt;).&amp;nbsp; Although this blog describes VS 2008, it applies to VS 2010 without any changes.&amp;nbsp; I tried to cheat and extend my service library dll service class (with changing the SVC code behind as well) but, alas, when I browsed to the service, it basically told me that the ServiceContract cannot be inherited.&amp;nbsp; So, to avoid that fight, I copied my library code into the new IIS hosted service project and removed the old library – I didn’t see a use for the old library outside of various hosting methods or for debugging…ah, debugging – hard to debug an IIS service with console write’s so I decided to keep the old console host so that I could see what was going on in the service though console writes (yes, archaic, I know – but works).&amp;nbsp; I added a normal reference to the new Library dll in the host console application – no other code needed to be changed.&lt;/p&gt; &lt;p&gt;Now my hosting/service solution looks like this:&lt;/p&gt; &lt;p&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg_3BN7o_NHkgUX4IsoDb17dTVXacMMn8JKo1rgvaKKcIyzMduAMoHt2dTel_PW-YaQ8_Mnqr-VQHmyYs5OLuGIjv5hyphenhyphenTIMZF5iWJD4d7-6vqyS5vMJwq_qQTiNE_S3RmKh50xVblmWBL8/s1600-h/image%25255B4%25255D.png&quot;&gt;&lt;img style=&quot;background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px&quot; title=&quot;image&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJC3rJym9JcbIhLMo8MFI0eNJgUNQGDyq0_ifmia30deQiZS6e02cp3z6K4qoqWvhshHApQZuTD_b7MTRvv-azVh7Dh9lVxPm1G9jPA5_dKT01tgKiRDxGvFEsjlYWvkxQwQQVRycAYSM/?imgmax=800&quot; width=&quot;324&quot; height=&quot;461&quot;&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;To publish the service to IIS, be sure to follow the instructions in the mentioned blog as VS will host it by default if those aren’t followed.&amp;nbsp; Then right click on the WCF project and click Publish.&amp;nbsp; A dialog box similar to the following should appear.&amp;nbsp; For my settings, I set the service URL to my local machine and the site/application to one of the similar examples shown (eg Default Web Site/MyApp).&amp;nbsp; Since this is a WCF service, I set the “Mark as IIS Application” and left everything else default.&lt;/p&gt; &lt;p&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpIc6n9_BPoFPlm5QpUexvlorMKmdM2oBv-t8hSn94DDNywIqRSGmRUQxsNl0m4S0mw14_yuSEWQG8AGxlY48JB1hWbB6wCrEgQAiGBPXXlmCSn3YMNvNlsLWdiFq5Dnx0N6r4MIzc-yM/s1600-h/image%25255B9%25255D.png&quot;&gt;&lt;img style=&quot;background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px&quot; title=&quot;image&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhMWOQw4f3yEpvPDiaD2eozcYz347dC18koMROy3QY_qF9AvhQWzQKR918XjfhxE_kff1_Vq7rw4b6Onu566e44sebFxpcejlZTbn4sXeJoVPl7QyDqh8NKQSgxPuafglBfyj-g7wpC2Es/?imgmax=800&quot; width=&quot;413&quot; height=&quot;555&quot;&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;After a successful publish, VS appears to update the Web.config file so it may ask if you want to update the file to the most recent changes.&lt;/p&gt; &lt;p&gt;To make sure everything works as expected, right click on the service file [yes, service file, not the project], then go to View In Browser.&amp;nbsp; The familiar “You have created a service.” should appear.&amp;nbsp; If not, check the Web config of the service and make sure the following line is set.&amp;nbsp; VS 2010 creates the web config file and, by default, sets this to true for you.&lt;/p&gt;&lt;pre style=&quot;font-family: consolas; background: white; color: black; font-size: 13px&quot;&gt;&lt;span style=&quot;color: blue&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #a31515&quot;&gt;serviceMetadata&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: red&quot;&gt;httpGetEnabled&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;=&lt;/span&gt;&quot;&lt;span style=&quot;color: blue&quot;&gt;true&lt;/span&gt;&quot;&lt;span style=&quot;color: blue&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;Now, if we start the project, we should see the console host, as normal, which, according to it’s app config file will be using port 8000 instead of the IIS default of port 80. So, in the client, this will need to be changed accordingly depending on whether we want the IIS version or the console hosted version.&amp;nbsp; For proof the host still works:&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjB_lC8xH7C8Ln74HA7PKi7cu8SCZpSiIGSQOCpAd7lZg4Vnu01WAe-Iq8-F9rE7V581RUEikDJ3UbEMSD_3OWP4cS50Mv0OKkMVTreg4OLLFPKeRyJVLzo6M8RnYqAySpOzAjm9G7ClVQ/s1600-h/image%25255B19%25255D.png&quot;&gt;&lt;img style=&quot;background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px&quot; title=&quot;image&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg0sV9-CI_EFve-8w9NQ3w90BlW4gs88pGy7XEGRF_0LYs1mSl93pd18PU6AkKsXI2fR8hShRWTqJw5I0Clso26TE_Oh3c39a2ZxiyD13rRbhy4Iu98lMSae_SUM3Ct5IfdEAVvOey9hSo/?imgmax=800&quot; width=&quot;440&quot; height=&quot;191&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;And with the client making a call against the console host&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhRk_yTNudpeTnP4JcqS0asJ3YXApEAnfJTQrAuThxuAtP6M5S8d8F3bRGN6CumxxAEgxld-pR6UyMHg1DOez8sw8uGi1p81qDVmK2H96bQ11kzzGD_DJ7-wF_U13Mxw19x5iMQGTYyWw/s1600-h/image%25255B30%25255D.png&quot;&gt;&lt;img style=&quot;background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px&quot; title=&quot;image&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjCSEfn8suYj_9oFumksfx4KfMGWV51BszwTKCnKezUsgHSZ4nJCUhhyphenhyphenRJlJSnxCD9NTDc5jWw7R06Njj3mMkrG411RTZan23UIz_c29VD_a0jhMZOEDMezveQMD4dj24QmvrWXx_C2LLE/?imgmax=800&quot; width=&quot;550&quot; height=&quot;292&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Unfortunately no easy way to tell if the IIS hosted version is working as expected (other than the fact it is using the exact same code, just a different hosting method).&amp;nbsp; The easy way to check communication is to change the app config of the client to point to port 80.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Run the client again and we get:&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiiutIJKcgWiPGfD8tNN_OJpNffEABoWIQd-OSKBUz8zGF6AC3NVVu0WEFRXN7mNEHidzsNMSfzZ7Xp9URi_b3rxCHd0UswvexIj5FuLmTbODA25gQRkgrs5UEwR-CtcD550s0cmvZGC2Q/s1600-h/image%25255B29%25255D.png&quot;&gt;&lt;img style=&quot;background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px&quot; title=&quot;image&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhK4qjNFctH27rkKbN_xde-lVMUPn9rsl94bkF_qoTIRNyKmGsvmFB4LmidTn42Kad2S8OHfI8ebif0SPrcHFCIKyL6fem10c4OO6T7RRgs-izI0RtTM8PhEcKDmty520m1dxFIS83iL_E/?imgmax=800&quot; width=&quot;530&quot; height=&quot;274&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Hmm…EndpointNotFoundException – but why?&amp;nbsp; Well, let’s look at the service again in IIS – viewing the service in the browser we get and address of http://localhost/ExpressRecipeWCFLibrary/UserService.svc.&amp;nbsp; But if we look at the client app config file we have:&lt;/p&gt;&lt;br /&gt;&lt;p&gt;http://localhost/UserService&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Ok, two problems – application name we set when we published is showing in the URL and so is the .svc.&amp;nbsp; Setting the app config service location fixes the problem, but, debugging with the console hosting app now goes away until it’s changed back.&amp;nbsp; (just for curiosity sake, I tried to publish without the application name and my VS crashed…so, probably not a good way to get around this issue).&amp;nbsp; Haven’t tried yet, but defining an endpoint for each the console and IIS host may be an option (an option which would have to be repeated for n services – could easily get nasty)…&amp;nbsp; A workaround is to set the console base address to be that of the IIS service address, just be sure to change the port number – seems to work for this case.&amp;nbsp; This may need a more elegant solution soon, maybe modifying the port or endpoint based on if it’s in DEBUG or just a normal build…anyway, something else to think about.&lt;/p&gt;  </content><link rel='replies' type='application/atom+xml' href='http://rhale78.blogspot.com/feeds/8333658906912853699/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://rhale78.blogspot.com/2011/07/trial-and-errorwcf-services-part-3.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/270091469191232126/posts/default/8333658906912853699'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/270091469191232126/posts/default/8333658906912853699'/><link rel='alternate' type='text/html' href='http://rhale78.blogspot.com/2011/07/trial-and-errorwcf-services-part-3.html' title='Trial and Error–WCF Services Part 3 (split to IIS Hosting)'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/09185478558704427023</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJC3rJym9JcbIhLMo8MFI0eNJgUNQGDyq0_ifmia30deQiZS6e02cp3z6K4qoqWvhshHApQZuTD_b7MTRvv-azVh7Dh9lVxPm1G9jPA5_dKT01tgKiRDxGvFEsjlYWvkxQwQQVRycAYSM/s72-c?imgmax=800" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-270091469191232126.post-8499792216754242489</id><published>2011-07-16T23:16:00.001-04:00</published><updated>2011-07-16T23:16:09.519-04:00</updated><title type='text'>Trial and Error–WCF Services Part 2</title><content type='html'>&lt;p&gt;As promised in my last WCF post, in this&amp;nbsp; post I’ll create the client that connects to the WCF service host that was created earlier.&amp;nbsp; Since the host is pretty simple at this point, so will the client and test be.&lt;/p&gt; &lt;p&gt;First things first, I need to create a project that’ll use the client – figured it would be easiest to do that in the same solution as the host.&amp;nbsp; So, I added a new project called ExpressRecipeServiceClient (technically this is poorly named as the client/proxy will be generated elsewhere).&lt;/p&gt; &lt;p&gt;Ok, so far so good – now to add the WCF reference, which in turn will generate the client/proxy code.&amp;nbsp; So, at the client project, I right click, go down to Add Service Reference.&amp;nbsp; Easy enough so far and is mostly the same as adding a project reference.&amp;nbsp; The Add Service Reference dialog comes up and I click Discover – thinking VS would see I have a WCF host.&amp;nbsp; Nope – nothing happens.&amp;nbsp; Ok, so I go back to the book and it says I need to manually start the host project without using debug…ok, try literally exactly that, start the host solution using Run, not Debug but I run into the problem of not being able to add any new references to any project that way.&amp;nbsp; I finally realize it means run it at the command line…so, I navigate over to the bin directory of the project and start the host there…host appears happy so I go back to VS and try to add the service through discover…still nothing.&amp;nbsp; So, I try making sure the service host is running by accessing the WSDL through IE – yep, works as it did.&amp;nbsp; I noticed on t e WSDL description that it says to use this URL to create a proxy – in my case, &lt;span style=&quot;color: blue&quot;&gt;&lt;font color=&quot;#000000&quot;&gt;&lt;a href=&quot;http://localhost:8000/UserService/?wsdl&quot;&gt;http://localhost:8000/UserService/?wsdl&lt;/a&gt;.&amp;nbsp; I put that in where it asks for address, then press go.&amp;nbsp; And, guess what, it appears to have worked.&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style=&quot;color: blue&quot;&gt;&lt;/span&gt;&lt;br&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhi24I8PVr2b-gHJsnXFKHCPvrFSO_jv0JD7IVOtxXxM-Yo7ZWhBo_7UsxDeYfQzxh66H7a7S0VYd0E3cPlfpo4FMgpyb0_VRRdk-NKV2k51cB78dmxrcd7aivDWliR6xmCZpqgdwbVv2w/s1600-h/image%25255B3%25255D.png&quot;&gt;&lt;img style=&quot;background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px&quot; title=&quot;image&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFd_97khwUwEbzh6_hGCYHRcsx1XlQXFvUj7LZX8OY51cq4Kdj6k4lec5XKFQzkMRoEsc6hB_mzUaZS4MLTlhvQGzS6WJ83fWrYeu3-gSI4YwpGnoSLW6qqW5lJaJKBEF2Y4KDZaEsCcM/?imgmax=800&quot; width=&quot;651&quot; height=&quot;527&quot;&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Great…now, set the namepace something useful (ExpressRecipeService in my case) and then click ok (ignoring the advanced options – for now).&amp;nbsp; A new reference will appear under Service Reference with the namespace that was provided earlier.&lt;/p&gt; &lt;p&gt;Now for the test.&amp;nbsp; I still have the WCF host running from the command line.&amp;nbsp; In the newly created client project, I make a call similar to this&lt;/p&gt; &lt;div style=&quot;padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px&quot; id=&quot;scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:bf73ea10-d135-4506-a750-c733bc42eeb3&quot; class=&quot;wlWriterEditableSmartContent&quot;&gt; &lt;div style=&quot;border: #000080 1px solid; color: #000; font-family: &#39;Courier New&#39;, Courier, Monospace; font-size: 10pt&quot;&gt; &lt;div style=&quot;background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px&quot;&gt;ExpressRecipeClient.cs&lt;/div&gt; &lt;div style=&quot;background: #ddd; max-height: 300px; overflow: auto&quot;&gt; &lt;ol style=&quot;background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px; white-space: nowrap&quot;&gt; &lt;li&gt;&lt;span style=&quot;color:#0000ff&quot;&gt;using&lt;/span&gt; System;&lt;/li&gt; &lt;li style=&quot;background: #f3f3f3&quot;&gt;&lt;span style=&quot;color:#0000ff&quot;&gt;using&lt;/span&gt; System.Collections.Generic;&lt;/li&gt; &lt;li&gt;&lt;span style=&quot;color:#0000ff&quot;&gt;using&lt;/span&gt; System.Linq;&lt;/li&gt; &lt;li style=&quot;background: #f3f3f3&quot;&gt;&lt;span style=&quot;color:#0000ff&quot;&gt;using&lt;/span&gt; System.Text;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style=&quot;background: #f3f3f3&quot;&gt;&lt;span style=&quot;color:#0000ff&quot;&gt;namespace&lt;/span&gt; ExpressRecipeServiceClient&lt;/li&gt; &lt;li&gt;{&lt;/li&gt; &lt;li style=&quot;background: #f3f3f3&quot;&gt;    &lt;span style=&quot;color:#0000ff&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color:#2b91af&quot;&gt;Program&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    {&lt;/li&gt; &lt;li style=&quot;background: #f3f3f3&quot;&gt;        &lt;span style=&quot;color:#0000ff&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color:#0000ff&quot;&gt;void&lt;/span&gt; Main(&lt;span style=&quot;color:#0000ff&quot;&gt;string&lt;/span&gt;[] args)&lt;/li&gt; &lt;li&gt;        {&lt;/li&gt; &lt;li style=&quot;background: #f3f3f3&quot;&gt;            ExpressRecipeService.&lt;span style=&quot;color:#2b91af&quot;&gt;ExpressRecipeUserContractClient&lt;/span&gt; client = &lt;span style=&quot;color:#0000ff&quot;&gt;new&lt;/span&gt; ExpressRecipeService.&lt;span style=&quot;color:#2b91af&quot;&gt;ExpressRecipeUserContractClient&lt;/span&gt;();&lt;/li&gt; &lt;li&gt;            client.AddUser(&lt;span style=&quot;color:#a31515&quot;&gt;&amp;quot;test1&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color:#a31515&quot;&gt;&amp;quot;test2&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color:#a31515&quot;&gt;&amp;quot;test3&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color:#a31515&quot;&gt;&amp;quot;test4&amp;quot;&lt;/span&gt;);&lt;/li&gt; &lt;li style=&quot;background: #f3f3f3&quot;&gt;        }&lt;/li&gt; &lt;li&gt;    }&lt;/li&gt; &lt;li style=&quot;background: #f3f3f3&quot;&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;Basically, create a new client for the host and call the only user-generated procedure, AddUser, with fake test parameters.&amp;nbsp; My expectation is that those will be printed out on the host console screen.&amp;nbsp; Guess it’s time to run, so F5.&lt;/p&gt; &lt;p&gt;Oops…”HTTP could not register URL &lt;a href=&quot;http://+:8000/UserService/&quot;&gt;http://+:8000/UserService/&lt;/a&gt;. Another application has already registered this URL with HTTP.SYS.”&amp;nbsp; Guess we should kill the console running host and try again.&amp;nbsp; Basically the error means something else is using that transport at that same port.&lt;/p&gt; &lt;p&gt;Kill the console host, then F5 again and here’s what I see from the host screen…well, nothing new – client never comes up but host does.&amp;nbsp; Gotta make the solution start multiple projects so set the host to start first, then set the client to start.&amp;nbsp; Run again and I get:&lt;/p&gt; &lt;p&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihje6-qsqLogW9WTWu2HFpKHaAGZXaAoPpXKRDXuACmvLmq8eAlvN9bsS5FaFvtzTh5PSXHDZOwNQxVq8zirwANvxgzlu3eVYXf1tEPtYDk6zNfKTbpGXWyXcPIU2hDuuA0YvNaArCqDU/s1600-h/image%25255B14%25255D.png&quot;&gt;&lt;img style=&quot;background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px&quot; title=&quot;image&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzYeviJh-9ept4lNd-pd-v5ShzFCPgJKBbDBR55DE2MerXmtf2xDRfrOn8wJ8kbx6rj6kWF-jPwYi89Jd9l85i3b_uEM9kelndtjaMCnR3wIc2gkyu4stUIU16G76CJO5uekrxTalwT1A/?imgmax=800&quot; width=&quot;696&quot; height=&quot;353&quot;&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Ok, that wasn’t goo bad…going to need to do a bit more complicated things in the host but so far so good.&lt;/p&gt;  </content><link rel='replies' type='application/atom+xml' href='http://rhale78.blogspot.com/feeds/8499792216754242489/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://rhale78.blogspot.com/2011/07/trial-and-errorwcf-services-part-2.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/270091469191232126/posts/default/8499792216754242489'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/270091469191232126/posts/default/8499792216754242489'/><link rel='alternate' type='text/html' href='http://rhale78.blogspot.com/2011/07/trial-and-errorwcf-services-part-2.html' title='Trial and Error–WCF Services Part 2'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/09185478558704427023</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFd_97khwUwEbzh6_hGCYHRcsx1XlQXFvUj7LZX8OY51cq4Kdj6k4lec5XKFQzkMRoEsc6hB_mzUaZS4MLTlhvQGzS6WJ83fWrYeu3-gSI4YwpGnoSLW6qqW5lJaJKBEF2Y4KDZaEsCcM/s72-c?imgmax=800" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-270091469191232126.post-3618296027688505691</id><published>2011-07-16T19:23:00.001-04:00</published><updated>2011-07-16T19:23:48.401-04:00</updated><category scheme="http://www.blogger.com/atom/ns#" term=".Net 4.0"/><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="Design Pattern"/><category scheme="http://www.blogger.com/atom/ns#" term="dynamic factory"/><category scheme="http://www.blogger.com/atom/ns#" term="factory pattern"/><category scheme="http://www.blogger.com/atom/ns#" term="inheritance"/><category scheme="http://www.blogger.com/atom/ns#" term="static constructor"/><title type='text'>Factories in C#-Basic, Cached, and Dynamic</title><content type='html'>&lt;h1&gt;Introduction&lt;/h1&gt; &lt;p&gt;It seems that one of the more common operations in modern object orientated languages is creating new objects.&amp;nbsp; In most languages, this is accomplished by using the “new” operator…this is nothing new for most of us out there who’ve been doing OO programming for any length of time.&amp;nbsp; For those who haven’t been, here’s the general idea – we have a class we want to create and use (let’s say a “Dog”) in our main program.&amp;nbsp; Here’s the Dog class:&lt;/p&gt; &lt;div style=&quot;padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px&quot; id=&quot;scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:70737f23-7b36-4f73-bc03-2f7606871421&quot; class=&quot;wlWriterSmartContent&quot;&gt; &lt;div style=&quot;border-bottom: #000080 1px solid; border-left: #000080 1px solid; font-family: &#39;Courier New&#39;, courier, monospace; color: #000; font-size: 10pt; border-top: #000080 1px solid; border-right: #000080 1px solid&quot;&gt; &lt;div style=&quot;padding-bottom: 2px; padding-left: 5px; padding-right: 5px; font-family: verdana, tahoma, arial, sans-serif; background: #000080; color: #fff; font-weight: bold; padding-top: 2px&quot;&gt;Dog.cs&lt;/div&gt; &lt;div style=&quot;background: #ddd; max-height: 300px; overflow: auto&quot;&gt; &lt;ol style=&quot;padding-bottom: 0px; margin: 0px 0px 0px 2.5em; padding-left: 5px; padding-right: 0px; background: #ffffff; padding-top: 0px&quot;&gt; &lt;li&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: #2b91af&quot;&gt;Dog&lt;/span&gt;  &lt;li style=&quot;background: #f3f3f3&quot;&gt;{  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt; AnimalType { &lt;span style=&quot;color: #0000ff&quot;&gt;get&lt;/span&gt;; &lt;span style=&quot;color: #0000ff&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;set&lt;/span&gt;; }  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; Dog()  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; AnimalType=&lt;span style=&quot;color: #a31515&quot;&gt;&quot;Dog&quot;&lt;/span&gt;;  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li&gt;&amp;nbsp; &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;void&lt;/span&gt; IntroduceSelf()  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.&lt;span style=&quot;color: #2b91af&quot;&gt;Console&lt;/span&gt;.WriteLine(IntroductionLine);  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.&lt;span style=&quot;color: #2b91af&quot;&gt;Console&lt;/span&gt;.WriteLine(Speak);  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.&lt;span style=&quot;color: #2b91af&quot;&gt;Console&lt;/span&gt;.WriteLine();  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt; IntroductionLine  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;get&lt;/span&gt;  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt; introLine = &lt;span style=&quot;color: #a31515&quot;&gt;&quot;Hello, I am a &quot;&lt;/span&gt; + AnimalType;  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; introLine;  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li&gt;&amp;nbsp; &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt; Speak  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;get&lt;/span&gt;  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #a31515&quot;&gt;&quot;Woof&quot;&lt;/span&gt;;  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li&gt;} &lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;And to create a new Dog we do this in our main program:&lt;/p&gt; &lt;div style=&quot;padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px&quot; id=&quot;scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:b2dfeaf0-72b1-4e55-8a5b-4f17e2e32985&quot; class=&quot;wlWriterSmartContent&quot;&gt; &lt;div style=&quot;border-bottom: #000080 1px solid; border-left: #000080 1px solid; font-family: &#39;Courier New&#39;, courier, monospace; color: #000; font-size: 10pt; border-top: #000080 1px solid; border-right: #000080 1px solid&quot;&gt; &lt;div style=&quot;padding-bottom: 2px; padding-left: 5px; padding-right: 5px; font-family: verdana, tahoma, arial, sans-serif; background: #000080; color: #fff; font-weight: bold; padding-top: 2px&quot;&gt;Program.cs&lt;/div&gt; &lt;div style=&quot;background: #ddd; max-height: 300px; overflow: auto&quot;&gt; &lt;ol style=&quot;padding-bottom: 0px; margin: 0px 0px 0px 2.5em; padding-left: 5px; padding-right: 0px; background: #ffffff; padding-top: 0px&quot;&gt; &lt;li&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: #2b91af&quot;&gt;Program&lt;/span&gt;  &lt;li style=&quot;background: #f3f3f3&quot;&gt;{  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;void&lt;/span&gt; Main(&lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt;[] args)  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #2b91af&quot;&gt;Dog&lt;/span&gt; dog = &lt;span style=&quot;color: #0000ff&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #2b91af&quot;&gt;Dog&lt;/span&gt;();  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dog.IntroduceSelf();  &lt;li&gt;&amp;nbsp; &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.&lt;span style=&quot;color: #2b91af&quot;&gt;Console&lt;/span&gt;.WriteLine(&lt;span style=&quot;color: #a31515&quot;&gt;&quot;Press &amp;lt;enter&amp;gt; to end&quot;&lt;/span&gt;);  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #2b91af&quot;&gt;Console&lt;/span&gt;.ReadLine();  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li&gt;} &lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;Ok, simple enough, right?&lt;/p&gt; &lt;p&gt;Well, let’s say the requirements expand and we now need to create a cat and a dog.&amp;nbsp; [ok, now, you ol fogies – I know you already know this…just skim down if you’re bored].&amp;nbsp; So, we create a new class named Cat that does pretty much the same thing as the Dog class did, with obvious exceptions.&amp;nbsp; [At this point, if you’re an OO programmer, alarm bells should be going off in your head – Cat class does pretty much the same thing as the Dog class].&lt;/p&gt; &lt;p&gt;So, here’s the Cat class -&lt;/p&gt; &lt;div style=&quot;padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px&quot; id=&quot;scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:1e7e8739-9599-4fd3-bab7-d3bdf432302c&quot; class=&quot;wlWriterEditableSmartContent&quot;&gt; &lt;div style=&quot;border: #000080 1px solid; color: #000; font-family: &#39;Courier New&#39;, Courier, Monospace; font-size: 10pt&quot;&gt; &lt;div style=&quot;background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px&quot;&gt;Cat.cs&lt;/div&gt; &lt;div style=&quot;background: #ddd; max-height: 300px; overflow: auto&quot;&gt; &lt;ol style=&quot;background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;&quot;&gt; &lt;li&gt;&lt;span style=&quot;color:#0000ff&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color:#0000ff&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color:#2b91af&quot;&gt;Cat&lt;/span&gt;&lt;/li&gt; &lt;li style=&quot;background: #f3f3f3&quot;&gt;    {&lt;/li&gt; &lt;li&gt;        &lt;span style=&quot;color:#0000ff&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color:#0000ff&quot;&gt;string&lt;/span&gt; AnimalType { &lt;span style=&quot;color:#0000ff&quot;&gt;get&lt;/span&gt;; &lt;span style=&quot;color:#0000ff&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color:#0000ff&quot;&gt;set&lt;/span&gt;; }&lt;/li&gt; &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;        &lt;span style=&quot;color:#0000ff&quot;&gt;public&lt;/span&gt; Cat()&lt;/li&gt; &lt;li style=&quot;background: #f3f3f3&quot;&gt;        {&lt;/li&gt; &lt;li&gt;            AnimalType = &lt;span style=&quot;color:#a31515&quot;&gt;&amp;quot;Cat&amp;quot;&lt;/span&gt;;&lt;/li&gt; &lt;li style=&quot;background: #f3f3f3&quot;&gt;        }&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style=&quot;background: #f3f3f3&quot;&gt;        &lt;span style=&quot;color:#0000ff&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color:#0000ff&quot;&gt;void&lt;/span&gt; IntroduceSelf()&lt;/li&gt; &lt;li&gt;        {&lt;/li&gt; &lt;li style=&quot;background: #f3f3f3&quot;&gt;            System.&lt;span style=&quot;color:#2b91af&quot;&gt;Console&lt;/span&gt;.WriteLine(IntroductionLine);&lt;/li&gt; &lt;li&gt;            System.&lt;span style=&quot;color:#2b91af&quot;&gt;Console&lt;/span&gt;.WriteLine(Speak);&lt;/li&gt; &lt;li style=&quot;background: #f3f3f3&quot;&gt;            System.&lt;span style=&quot;color:#2b91af&quot;&gt;Console&lt;/span&gt;.WriteLine();&lt;/li&gt; &lt;li&gt;        }&lt;/li&gt; &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;        &lt;span style=&quot;color:#0000ff&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color:#0000ff&quot;&gt;string&lt;/span&gt; IntroductionLine&lt;/li&gt; &lt;li style=&quot;background: #f3f3f3&quot;&gt;        {&lt;/li&gt; &lt;li&gt;            &lt;span style=&quot;color:#0000ff&quot;&gt;get&lt;/span&gt;&lt;/li&gt; &lt;li style=&quot;background: #f3f3f3&quot;&gt;            {&lt;/li&gt; &lt;li&gt;                &lt;span style=&quot;color:#0000ff&quot;&gt;string&lt;/span&gt; introLine = &lt;span style=&quot;color:#a31515&quot;&gt;&amp;quot;Hello, I am a &amp;quot;&lt;/span&gt; + AnimalType;&lt;/li&gt; &lt;li style=&quot;background: #f3f3f3&quot;&gt;                &lt;span style=&quot;color:#0000ff&quot;&gt;return&lt;/span&gt; introLine;&lt;/li&gt; &lt;li&gt;            }&lt;/li&gt; &lt;li style=&quot;background: #f3f3f3&quot;&gt;        }&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style=&quot;background: #f3f3f3&quot;&gt;        &lt;span style=&quot;color:#0000ff&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color:#0000ff&quot;&gt;string&lt;/span&gt; Speak&lt;/li&gt; &lt;li&gt;        {&lt;/li&gt; &lt;li style=&quot;background: #f3f3f3&quot;&gt;            &lt;span style=&quot;color:#0000ff&quot;&gt;get&lt;/span&gt;&lt;/li&gt; &lt;li&gt;            {&lt;/li&gt; &lt;li style=&quot;background: #f3f3f3&quot;&gt;                &lt;span style=&quot;color:#0000ff&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color:#a31515&quot;&gt;&amp;quot;Meow&amp;quot;&lt;/span&gt;;&lt;/li&gt; &lt;li&gt;            }&lt;/li&gt; &lt;li style=&quot;background: #f3f3f3&quot;&gt;        }&lt;/li&gt; &lt;li&gt;    }&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;And our main program to create a dog and cat looks like this:&lt;/p&gt; &lt;div style=&quot;padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px&quot; id=&quot;scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:0fd52c94-90d0-4c31-9bdc-d2b44bb79de2&quot; class=&quot;wlWriterEditableSmartContent&quot;&gt; &lt;div style=&quot;border: #000080 1px solid; color: #000; font-family: &#39;Courier New&#39;, Courier, Monospace; font-size: 10pt&quot;&gt; &lt;div style=&quot;background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px&quot;&gt;Program.cs&lt;/div&gt; &lt;div style=&quot;background: #ddd; max-height: 300px; overflow: auto&quot;&gt; &lt;ol style=&quot;background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;&quot;&gt; &lt;li&gt;&lt;span style=&quot;color:#0000ff&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color:#2b91af&quot;&gt;Program&lt;/span&gt;&lt;/li&gt; &lt;li style=&quot;background: #f3f3f3&quot;&gt;    {&lt;/li&gt; &lt;li&gt;        &lt;span style=&quot;color:#0000ff&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color:#0000ff&quot;&gt;void&lt;/span&gt; Main(&lt;span style=&quot;color:#0000ff&quot;&gt;string&lt;/span&gt;[] args)&lt;/li&gt; &lt;li style=&quot;background: #f3f3f3&quot;&gt;        {&lt;/li&gt; &lt;li&gt;            &lt;span style=&quot;color:#2b91af&quot;&gt;Dog&lt;/span&gt; dog = &lt;span style=&quot;color:#0000ff&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color:#2b91af&quot;&gt;Dog&lt;/span&gt;();&lt;/li&gt; &lt;li style=&quot;background: #f3f3f3&quot;&gt;            dog.IntroduceSelf();&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style=&quot;background: #f3f3f3&quot;&gt;            &lt;span style=&quot;color:#2b91af&quot;&gt;Cat&lt;/span&gt; cat = &lt;span style=&quot;color:#0000ff&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color:#2b91af&quot;&gt;Cat&lt;/span&gt;();&lt;/li&gt; &lt;li&gt;            cat.IntroduceSelf();&lt;/li&gt; &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;            System.&lt;span style=&quot;color:#2b91af&quot;&gt;Console&lt;/span&gt;.WriteLine(&lt;span style=&quot;color:#a31515&quot;&gt;&amp;quot;Press &amp;lt;enter&amp;gt; to end&amp;quot;&lt;/span&gt;);&lt;/li&gt; &lt;li style=&quot;background: #f3f3f3&quot;&gt;            &lt;span style=&quot;color:#2b91af&quot;&gt;Console&lt;/span&gt;.ReadLine();&lt;/li&gt; &lt;li&gt;        }&lt;/li&gt; &lt;li style=&quot;background: #f3f3f3&quot;&gt;    }&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;Ok, not bad…and we solved the requirements…but, look at all that duplicated code…what if the requirements change again (and, believe me, they will)?&amp;nbsp; What if we added 50 animal types and then we found a bug that was common in all that code…50 classes would have to change to fix that bug.&amp;nbsp; What’s the answer?&amp;nbsp; Using the OO concept of inheritance.&lt;/p&gt; &lt;h2&gt;Brief Overview of Inheritance (as it pertains to Factories)&lt;/h2&gt; &lt;p&gt;One of the key features of inheritance is the ability to reuse code from a class higher up the inheritance chain (such as a parent or grandparent [or from a base class in C# terms]).&amp;nbsp; This reused code can be in the form of functions/procedures, data members, or properties (I’m specifically referring to class inheritance here, not inheritance via interfaces).&amp;nbsp; So, what does this have to do with factories and creation of objects – inheritance is a prerequisite to getting a factory to work for object creation.&amp;nbsp; So, let’s go ahead and use inheritance and get rid of some of this duplicated code…and, while we’re at it, let’s create a new animal class for a pig.&lt;/p&gt; &lt;p&gt;We’ll start with an abstract base class.&amp;nbsp; We really don’t want to be creating an animal by itself and there are some things the animals themselves will know how to do that this base animal class won’t (i.e. how to speak).&lt;/p&gt; &lt;div style=&quot;padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px&quot; id=&quot;scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:df4deae4-c122-42ae-8817-f9991fe3d177&quot; class=&quot;wlWriterEditableSmartContent&quot;&gt; &lt;div style=&quot;border: #000080 1px solid; color: #000; font-family: &#39;Courier New&#39;, Courier, Monospace; font-size: 10pt&quot;&gt; &lt;div style=&quot;background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px&quot;&gt;AbstractAnimalBase.cs&lt;/div&gt; &lt;div style=&quot;background: #ddd; max-height: 300px; overflow: auto&quot;&gt; &lt;ol style=&quot;background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;&quot;&gt; &lt;li&gt;&lt;span style=&quot;color:#0000ff&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color:#0000ff&quot;&gt;abstract&lt;/span&gt; &lt;span style=&quot;color:#0000ff&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color:#2b91af&quot;&gt;AbstractAnimalBase&lt;/span&gt;&lt;/li&gt; &lt;li style=&quot;background: #f3f3f3&quot;&gt;    {&lt;/li&gt; &lt;li&gt;        &lt;span style=&quot;color:#0000ff&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color:#0000ff&quot;&gt;string&lt;/span&gt; AnimalType { &lt;span style=&quot;color:#0000ff&quot;&gt;get&lt;/span&gt;; &lt;span style=&quot;color:#0000ff&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color:#0000ff&quot;&gt;set&lt;/span&gt;; }&lt;/li&gt; &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;        &lt;span style=&quot;color:#0000ff&quot;&gt;public&lt;/span&gt; AbstractAnimalBase(&lt;span style=&quot;color:#0000ff&quot;&gt;string&lt;/span&gt; type)&lt;/li&gt; &lt;li style=&quot;background: #f3f3f3&quot;&gt;        {&lt;/li&gt; &lt;li&gt;            AnimalType = type;&lt;/li&gt; &lt;li style=&quot;background: #f3f3f3&quot;&gt;        }&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style=&quot;background: #f3f3f3&quot;&gt;        &lt;span style=&quot;color:#0000ff&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color:#0000ff&quot;&gt;void&lt;/span&gt; IntroduceSelf()&lt;/li&gt; &lt;li&gt;        {&lt;/li&gt; &lt;li style=&quot;background: #f3f3f3&quot;&gt;            System.&lt;span style=&quot;color:#2b91af&quot;&gt;Console&lt;/span&gt;.WriteLine(IntroductionLine);&lt;/li&gt; &lt;li&gt;            System.&lt;span style=&quot;color:#2b91af&quot;&gt;Console&lt;/span&gt;.WriteLine(Speak);&lt;/li&gt; &lt;li style=&quot;background: #f3f3f3&quot;&gt;            System.&lt;span style=&quot;color:#2b91af&quot;&gt;Console&lt;/span&gt;.WriteLine();&lt;/li&gt; &lt;li&gt;        }&lt;/li&gt; &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;        &lt;span style=&quot;color:#0000ff&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color:#0000ff&quot;&gt;virtual&lt;/span&gt; &lt;span style=&quot;color:#0000ff&quot;&gt;string&lt;/span&gt; IntroductionLine&lt;/li&gt; &lt;li style=&quot;background: #f3f3f3&quot;&gt;        {&lt;/li&gt; &lt;li&gt;            &lt;span style=&quot;color:#0000ff&quot;&gt;get&lt;/span&gt;&lt;/li&gt; &lt;li style=&quot;background: #f3f3f3&quot;&gt;            {&lt;/li&gt; &lt;li&gt;                &lt;span style=&quot;color:#0000ff&quot;&gt;string&lt;/span&gt; introLine = &lt;span style=&quot;color:#a31515&quot;&gt;&amp;quot;Hello, I am a &amp;quot;&lt;/span&gt; + AnimalType;&lt;/li&gt; &lt;li style=&quot;background: #f3f3f3&quot;&gt;                &lt;span style=&quot;color:#0000ff&quot;&gt;return&lt;/span&gt; introLine;&lt;/li&gt; &lt;li&gt;            }&lt;/li&gt; &lt;li style=&quot;background: #f3f3f3&quot;&gt;        }&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style=&quot;background: #f3f3f3&quot;&gt;        &lt;span style=&quot;color:#0000ff&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color:#0000ff&quot;&gt;abstract&lt;/span&gt; &lt;span style=&quot;color:#0000ff&quot;&gt;string&lt;/span&gt; Speak&lt;/li&gt; &lt;li&gt;        {&lt;/li&gt; &lt;li style=&quot;background: #f3f3f3&quot;&gt;            &lt;span style=&quot;color:#0000ff&quot;&gt;get&lt;/span&gt;;&lt;/li&gt; &lt;li&gt;        }&lt;/li&gt; &lt;li style=&quot;background: #f3f3f3&quot;&gt;    }&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;Ok, now for the dog, cat, and pig classes that will use this base class.&amp;nbsp; Take a look at how much shorter these are than the original version that didn’t use inheritance.&lt;/p&gt; &lt;div style=&quot;padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px&quot; id=&quot;scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:6f2e65a1-b836-4f5c-82bf-9fdaacf24797&quot; class=&quot;wlWriterEditableSmartContent&quot;&gt; &lt;div style=&quot;border: #000080 1px solid; color: #000; font-family: &#39;Courier New&#39;, Courier, Monospace; font-size: 10pt&quot;&gt; &lt;div style=&quot;background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px&quot;&gt;Dog.cs&lt;/div&gt; &lt;div style=&quot;background: #ddd; max-height: 400px; overflow: auto&quot;&gt; &lt;ol style=&quot;background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;&quot;&gt; &lt;li&gt;&lt;span style=&quot;color:#0000ff&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color:#0000ff&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color:#2b91af&quot;&gt;Dog&lt;/span&gt; : &lt;span style=&quot;color:#2b91af&quot;&gt;AbstractAnimalBase&lt;/span&gt;&lt;/li&gt; &lt;li style=&quot;background: #f3f3f3&quot;&gt;    {&lt;/li&gt; &lt;li&gt;        &lt;span style=&quot;color:#0000ff&quot;&gt;public&lt;/span&gt; Dog()&lt;/li&gt; &lt;li style=&quot;background: #f3f3f3&quot;&gt;            : &lt;span style=&quot;color:#0000ff&quot;&gt;base&lt;/span&gt;(&lt;span style=&quot;color:#a31515&quot;&gt;&amp;quot;Dog&amp;quot;&lt;/span&gt;)&lt;/li&gt; &lt;li&gt;        {&lt;/li&gt; &lt;li style=&quot;background: #f3f3f3&quot;&gt;        }&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style=&quot;background: #f3f3f3&quot;&gt;        &lt;span style=&quot;color:#0000ff&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color:#0000ff&quot;&gt;override&lt;/span&gt; &lt;span style=&quot;color:#0000ff&quot;&gt;string&lt;/span&gt; Speak&lt;/li&gt; &lt;li&gt;        {&lt;/li&gt; &lt;li style=&quot;background: #f3f3f3&quot;&gt;            &lt;span style=&quot;color:#0000ff&quot;&gt;get&lt;/span&gt; { &lt;span style=&quot;color:#0000ff&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color:#a31515&quot;&gt;&amp;quot;Woof&amp;quot;&lt;/span&gt;; }&lt;/li&gt; &lt;li&gt;        }&lt;/li&gt; &lt;li style=&quot;background: #f3f3f3&quot;&gt;    }&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;div style=&quot;padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px&quot; id=&quot;scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:81d89a76-8760-43c1-82ee-019cb8349e69&quot; class=&quot;wlWriterEditableSmartContent&quot;&gt; &lt;div style=&quot;border: #000080 1px solid; color: #000; font-family: &#39;Courier New&#39;, Courier, Monospace; font-size: 10pt&quot;&gt; &lt;div style=&quot;background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px&quot;&gt;Cat.cs&lt;/div&gt; &lt;div style=&quot;background: #ddd; max-height: 300px; overflow: auto&quot;&gt; &lt;ol style=&quot;background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;&quot;&gt; &lt;li&gt;&lt;span style=&quot;color:#0000ff&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color:#0000ff&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color:#2b91af&quot;&gt;Cat&lt;/span&gt; : &lt;span style=&quot;color:#2b91af&quot;&gt;AbstractAnimalBase&lt;/span&gt;&lt;/li&gt; &lt;li style=&quot;background: #f3f3f3&quot;&gt;    {&lt;/li&gt; &lt;li&gt;        &lt;span style=&quot;color:#0000ff&quot;&gt;public&lt;/span&gt; Cat()&lt;/li&gt; &lt;li style=&quot;background: #f3f3f3&quot;&gt;            : &lt;span style=&quot;color:#0000ff&quot;&gt;base&lt;/span&gt;(&lt;span style=&quot;color:#a31515&quot;&gt;&amp;quot;Cat&amp;quot;&lt;/span&gt;)&lt;/li&gt; &lt;li&gt;        {&lt;/li&gt; &lt;li style=&quot;background: #f3f3f3&quot;&gt;        }&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style=&quot;background: #f3f3f3&quot;&gt;        &lt;span style=&quot;color:#0000ff&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color:#0000ff&quot;&gt;override&lt;/span&gt; &lt;span style=&quot;color:#0000ff&quot;&gt;string&lt;/span&gt; Speak&lt;/li&gt; &lt;li&gt;        {&lt;/li&gt; &lt;li style=&quot;background: #f3f3f3&quot;&gt;            &lt;span style=&quot;color:#0000ff&quot;&gt;get&lt;/span&gt; { &lt;span style=&quot;color:#0000ff&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color:#a31515&quot;&gt;&amp;quot;Meow&amp;quot;&lt;/span&gt;; }&lt;/li&gt; &lt;li&gt;        }&lt;/li&gt; &lt;li style=&quot;background: #f3f3f3&quot;&gt;    }&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;div style=&quot;padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px&quot; id=&quot;scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:6bacebf4-02bc-41bf-b53e-89b357b3e2eb&quot; class=&quot;wlWriterEditableSmartContent&quot;&gt; &lt;div style=&quot;border: #000080 1px solid; color: #000; font-family: &#39;Courier New&#39;, Courier, Monospace; font-size: 10pt&quot;&gt; &lt;div style=&quot;background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px&quot;&gt;Pig.cs&lt;/div&gt; &lt;div style=&quot;background: #ddd; max-height: 300px; overflow: auto&quot;&gt; &lt;ol style=&quot;background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;&quot;&gt; &lt;li&gt;&lt;span style=&quot;color:#0000ff&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color:#0000ff&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color:#2b91af&quot;&gt;Pig&lt;/span&gt; : &lt;span style=&quot;color:#2b91af&quot;&gt;AbstractAnimalBase&lt;/span&gt;&lt;/li&gt; &lt;li style=&quot;background: #f3f3f3&quot;&gt;    {&lt;/li&gt; &lt;li&gt;        &lt;span style=&quot;color:#0000ff&quot;&gt;public&lt;/span&gt; Pig()&lt;/li&gt; &lt;li style=&quot;background: #f3f3f3&quot;&gt;            : &lt;span style=&quot;color:#0000ff&quot;&gt;base&lt;/span&gt;(&lt;span style=&quot;color:#a31515&quot;&gt;&amp;quot;Pig&amp;quot;&lt;/span&gt;)&lt;/li&gt; &lt;li&gt;        {&lt;/li&gt; &lt;li style=&quot;background: #f3f3f3&quot;&gt;        }&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style=&quot;background: #f3f3f3&quot;&gt;        &lt;span style=&quot;color:#0000ff&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color:#0000ff&quot;&gt;override&lt;/span&gt; &lt;span style=&quot;color:#0000ff&quot;&gt;string&lt;/span&gt; Speak&lt;/li&gt; &lt;li&gt;        {&lt;/li&gt; &lt;li style=&quot;background: #f3f3f3&quot;&gt;            &lt;span style=&quot;color:#0000ff&quot;&gt;get&lt;/span&gt; { &lt;span style=&quot;color:#0000ff&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color:#a31515&quot;&gt;&amp;quot;Oink&amp;quot;&lt;/span&gt;; }&lt;/li&gt; &lt;li&gt;        }&lt;/li&gt; &lt;li style=&quot;background: #f3f3f3&quot;&gt;    }&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;Ok, now to the meat of this post.&lt;/p&gt; &lt;h1&gt;Introduction to Factories&lt;/h1&gt; &lt;p&gt;So, what is a factory anyway and what can it do for us?&amp;nbsp; In layman terms, a factory is a piece of code that returns back a specific object from a given input.&amp;nbsp; Ok, so what’s so special about that, right? – new does that for me.&amp;nbsp; That’s correct, but, what if you don’t know what type of object you want while you’re coding?&amp;nbsp; That’s where the factory comes in – you tell the factory what type of object you want and it will return the object needed for that type to you.&amp;nbsp; In more programmer speak, a factory is one of the Gang of Four design patterns that is used to create objects without having to specify the exact class that will be created.&lt;/p&gt; &lt;p&gt;Yes, I know, you’re the programmer and you will always know what object you need and when - will you though?&amp;nbsp; Let’s say you’re reading a config file and wanting to do certain operations or load certain values based on the config – do you always know what and how it will be configured?&amp;nbsp; Or, let’s say you’re reading a database and you’ll have to load data from different tables depending on what the value of a specific field is…or, you’re looking at the file system for images and you come across a JPG and the next image is a GIF.&amp;nbsp; Each of these is a good candidate for a factory.&lt;/p&gt; &lt;p&gt;Typically, a factory is a static class and/or a static method.&amp;nbsp; Having the factory class static allows access to it without having to create an instance of the factory class.&lt;/p&gt; &lt;h2&gt;Basic Factories&lt;/h2&gt; &lt;h3&gt;Factories using Strings&lt;/h3&gt; &lt;p&gt;The factory method will generally return the common base class or common interface of the objects that could be created by the method…normally the structure is simple, either in a if-else or in a switch statement.&amp;nbsp; So, for the animal factory, we’d have something like the following code:&lt;/p&gt; &lt;div style=&quot;padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px&quot; id=&quot;scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:a180ea32-07c5-4cd9-af1f-747ec41c8913&quot; class=&quot;wlWriterSmartContent&quot;&gt; &lt;div style=&quot;border-bottom: #000080 1px solid; border-left: #000080 1px solid; font-family: &#39;Courier New&#39;, courier, monospace; color: #000; font-size: 10pt; border-top: #000080 1px solid; border-right: #000080 1px solid&quot;&gt; &lt;div style=&quot;padding-bottom: 2px; padding-left: 5px; padding-right: 5px; font-family: verdana, tahoma, arial, sans-serif; background: #000080; color: #fff; font-weight: bold; padding-top: 2px&quot;&gt;AnimalFactory.cs&lt;/div&gt; &lt;div style=&quot;background: #ddd; overflow: auto&quot;&gt; &lt;ol style=&quot;padding-bottom: 0px; margin: 0px 0px 0px 2.5em; padding-left: 5px; padding-right: 0px; background: #ffffff; padding-top: 0px&quot;&gt; &lt;li&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: #2b91af&quot;&gt;AnimalFactory&lt;/span&gt;  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #2b91af&quot;&gt;AbstractAnimalBase&lt;/span&gt; CreateAnimal(&lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt; type)  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; type = type.ToLower().Trim();  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;switch&lt;/span&gt; (type)  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;case&lt;/span&gt; &lt;span style=&quot;color: #a31515&quot;&gt;&quot;dog&quot;&lt;/span&gt;:  &lt;li&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; &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #2b91af&quot;&gt;Dog&lt;/span&gt;();  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;case&lt;/span&gt; &lt;span style=&quot;color: #a31515&quot;&gt;&quot;cat&quot;&lt;/span&gt;:  &lt;li&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; &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #2b91af&quot;&gt;Cat&lt;/span&gt;();  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;case&lt;/span&gt; &lt;span style=&quot;color: #a31515&quot;&gt;&quot;pig&quot;&lt;/span&gt;:  &lt;li&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; &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #2b91af&quot;&gt;Pig&lt;/span&gt;();  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;default&lt;/span&gt;:  &lt;li&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; &lt;span style=&quot;color: #0000ff&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #2b91af&quot;&gt;Exception&lt;/span&gt;(&lt;span style=&quot;color: #2b91af&quot;&gt;String&lt;/span&gt;.Format(&lt;span style=&quot;color: #a31515&quot;&gt;&quot;Unknown animal type {0}&quot;&lt;/span&gt;, type));  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt; &lt;h3&gt;Factories using Enumerations&lt;/h3&gt; &lt;p&gt;A complaint with the above code is that it’s using strings to do the matching, which some claim is inefficient (due partly to the to lower and trim calls) and error prone (if you misspell, it’ll fail).&amp;nbsp; This can easily be changed to use an enumeration, which will gain some speed (no need for string manipulation) and is less error prone but adds a little bit more maintenance to the code – the programmer has to update the enum as well as the factory code.&amp;nbsp; Here’s the same code but using an enumeration instead:&lt;/p&gt; &lt;div style=&quot;padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px&quot; id=&quot;scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:f527e1a5-7c64-4da4-b354-1e17bcfcf782&quot; class=&quot;wlWriterSmartContent&quot;&gt; &lt;div style=&quot;border-bottom: #000080 1px solid; border-left: #000080 1px solid; font-family: &#39;Courier New&#39;, courier, monospace; color: #000; font-size: 10pt; border-top: #000080 1px solid; border-right: #000080 1px solid&quot;&gt; &lt;div style=&quot;padding-bottom: 2px; padding-left: 5px; padding-right: 5px; font-family: verdana, tahoma, arial, sans-serif; background: #000080; color: #fff; font-weight: bold; padding-top: 2px&quot;&gt;AnimalFactory.cs&lt;/div&gt; &lt;div style=&quot;background: #ddd; max-height: 300px; overflow: auto&quot;&gt; &lt;ol style=&quot;padding-bottom: 0px; margin: 0px 0px 0px 2.5em; padding-left: 5px; padding-right: 0px; background: #ffffff; padding-top: 0px&quot;&gt; &lt;li&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: #2b91af&quot;&gt;AnimalFactory&lt;/span&gt;  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;enum&lt;/span&gt; &lt;span style=&quot;color: #2b91af&quot;&gt;AnimalEnum&lt;/span&gt;  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dog,  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Cat,  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Pig  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; };  &lt;li&gt;&amp;nbsp; &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #2b91af&quot;&gt;AbstractAnimalBase&lt;/span&gt; CreateAnimal(&lt;span style=&quot;color: #2b91af&quot;&gt;AnimalEnum&lt;/span&gt; type)  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;switch&lt;/span&gt; (type)  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;case&lt;/span&gt; &lt;span style=&quot;color: #2b91af&quot;&gt;AnimalEnum&lt;/span&gt;.Dog :  &lt;li&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; &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #2b91af&quot;&gt;Dog&lt;/span&gt;();  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;case&lt;/span&gt; &lt;span style=&quot;color: #2b91af&quot;&gt;AnimalEnum&lt;/span&gt;.Cat:  &lt;li&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; &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #2b91af&quot;&gt;Cat&lt;/span&gt;();  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;case&lt;/span&gt; &lt;span style=&quot;color: #2b91af&quot;&gt;AnimalEnum&lt;/span&gt;.Pig:  &lt;li&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; &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #2b91af&quot;&gt;Pig&lt;/span&gt;();  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;default&lt;/span&gt;:  &lt;li&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; &lt;span style=&quot;color: #0000ff&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #2b91af&quot;&gt;Exception&lt;/span&gt;(&lt;span style=&quot;color: #2b91af&quot;&gt;String&lt;/span&gt;.Format(&lt;span style=&quot;color: #a31515&quot;&gt;&quot;Unknown animal type {0}&quot;&lt;/span&gt;, type));  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;Well, that’s it for the factory, right?&amp;nbsp; Well, in the general case, yes…but, there are a couple specific instances that I’ve found a use for lately that someone else may be interested in.&lt;/p&gt; &lt;h2&gt;Cached Factories&lt;/h2&gt; &lt;p&gt;There are times when creating a class is a long running process and you want to cache this data so you don’t kill your performance, but, the classes that do this all inherit from a base class so they are candidates for a factory pattern.&amp;nbsp; The sample factories above would create a new animal each time that type is requested – which could run a long-running process.&amp;nbsp; The cached factory helps with this situation…one thing to note with the cached factory it will return back the same object instance for a specific given type (not that this isn’t necessarily a singleton instance of a class).&amp;nbsp; So, for example, using the animal example above, the program requests a dog for the first time, a dog (#1) is created and returned back to the caller…on the second call to get a dog, dog (#1) is still returned to the caller…let’s say the code is slightly different than above and we return back a dog for an input of “mut”…with this situation, the program passes in “mut” and we get back a different instance of a dog (#2).&amp;nbsp; So, don’t get cached returns confused with singletons.&lt;/p&gt; &lt;p&gt;Now, for the code for a cached factory.&amp;nbsp; Pretty similar to the others but it uses a dictionary to keep hold the type and the returned value.&amp;nbsp; The code could easily be expanded to allow removal of cached values, etc, if needed.&lt;/p&gt; &lt;div style=&quot;padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px&quot; id=&quot;scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:785099c6-a712-420d-ab8e-bc1bb7ed94c7&quot; class=&quot;wlWriterSmartContent&quot;&gt; &lt;div style=&quot;border-bottom: #000080 1px solid; border-left: #000080 1px solid; font-family: &#39;Courier New&#39;, courier, monospace; color: #000; font-size: 10pt; border-top: #000080 1px solid; border-right: #000080 1px solid&quot;&gt; &lt;div style=&quot;padding-bottom: 2px; padding-left: 5px; padding-right: 5px; font-family: verdana, tahoma, arial, sans-serif; background: #000080; color: #fff; font-weight: bold; padding-top: 2px&quot;&gt;AnimalFactory.cs&lt;/div&gt; &lt;div style=&quot;background: #ddd; max-height: 300px; overflow: auto&quot;&gt; &lt;ol style=&quot;padding-bottom: 0px; margin: 0px 0px 0px 2.5em; padding-left: 5px; padding-right: 0px; white-space: nowrap; background: #ffffff; padding-top: 0px&quot;&gt; &lt;li&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;using&lt;/span&gt; System.Collections.Generic;  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: #2b91af&quot;&gt;AnimalFactory&lt;/span&gt;  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #2b91af&quot;&gt;Dictionary&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt;, &lt;span style=&quot;color: #2b91af&quot;&gt;AbstractAnimalBase&lt;/span&gt;&amp;gt; AnimalCache { &lt;span style=&quot;color: #0000ff&quot;&gt;get&lt;/span&gt;; &lt;span style=&quot;color: #0000ff&quot;&gt;set&lt;/span&gt;; }  &lt;li&gt;&amp;nbsp; &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #2b91af&quot;&gt;AbstractAnimalBase&lt;/span&gt; CreateAnimalCached(&lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt; type)  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;if&lt;/span&gt; (AnimalCache == &lt;span style=&quot;color: #0000ff&quot;&gt;null&lt;/span&gt;)  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; AnimalCache = &lt;span style=&quot;color: #0000ff&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #2b91af&quot;&gt;Dictionary&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt;, &lt;span style=&quot;color: #2b91af&quot;&gt;AbstractAnimalBase&lt;/span&gt;&amp;gt;();  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; type = type.ToLower().Trim();  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;if&lt;/span&gt; (!AnimalCache.ContainsKey(type))  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #2b91af&quot;&gt;AbstractAnimalBase&lt;/span&gt; animal;  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;switch&lt;/span&gt; (type)  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;case&lt;/span&gt; &lt;span style=&quot;color: #a31515&quot;&gt;&quot;dog&quot;&lt;/span&gt;:  &lt;li&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; animal = &lt;span style=&quot;color: #0000ff&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #2b91af&quot;&gt;Dog&lt;/span&gt;();  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;break&lt;/span&gt;;  &lt;li&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; &lt;span style=&quot;color: #0000ff&quot;&gt;case&lt;/span&gt; &lt;span style=&quot;color: #a31515&quot;&gt;&quot;cat&quot;&lt;/span&gt;:  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; animal = &lt;span style=&quot;color: #0000ff&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #2b91af&quot;&gt;Cat&lt;/span&gt;();  &lt;li&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; &lt;span style=&quot;color: #0000ff&quot;&gt;break&lt;/span&gt;;  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;case&lt;/span&gt; &lt;span style=&quot;color: #a31515&quot;&gt;&quot;pig&quot;&lt;/span&gt;:  &lt;li&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; animal = &lt;span style=&quot;color: #0000ff&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #2b91af&quot;&gt;Pig&lt;/span&gt;();  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;break&lt;/span&gt;;  &lt;li&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; &lt;span style=&quot;color: #0000ff&quot;&gt;default&lt;/span&gt;:  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #2b91af&quot;&gt;Exception&lt;/span&gt;(&lt;span style=&quot;color: #2b91af&quot;&gt;String&lt;/span&gt;.Format(&lt;span style=&quot;color: #a31515&quot;&gt;&quot;Unknown animal type {0}&quot;&lt;/span&gt;, type));  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; AnimalCache.Add(type,animal);  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; AnimalCache[type];  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt; &lt;h2&gt;Alternate “Factory” (Cache)&lt;/h2&gt; &lt;p&gt;An alternate version of the above factory eliminates the switch statement – so, each animal object will be created and cached…but, each object must manually be created outside the factory (hmm, kinda longer a factory if the object is created elsewhere, is it?) – but that add could be technically done from anywhere, according to the permission of the function/class.&amp;nbsp; So, the main method could add to the factory and other classes within the application use the factory with what was loaded from main.&lt;/p&gt; &lt;div style=&quot;padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px&quot; id=&quot;scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:ed06bf58-b087-4a50-bd99-0edcb6ba8454&quot; class=&quot;wlWriterSmartContent&quot;&gt; &lt;div style=&quot;border-bottom: #000080 1px solid; border-left: #000080 1px solid; font-family: &#39;Courier New&#39;, courier, monospace; color: #000; font-size: 10pt; border-top: #000080 1px solid; border-right: #000080 1px solid&quot;&gt; &lt;div style=&quot;padding-bottom: 2px; padding-left: 5px; padding-right: 5px; font-family: verdana, tahoma, arial, sans-serif; background: #000080; color: #fff; font-weight: bold; padding-top: 2px&quot;&gt;AnimalFactory.cs&lt;/div&gt; &lt;div style=&quot;background: #ddd; max-height: 300px; overflow: auto&quot;&gt; &lt;ol style=&quot;padding-bottom: 0px; margin: 0px 0px 0px 2.5em; padding-left: 5px; padding-right: 0px; white-space: nowrap; background: #ffffff; padding-top: 0px&quot;&gt; &lt;li&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;using&lt;/span&gt; System.Collections.Generic;  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: #2b91af&quot;&gt;AnimalFactory&lt;/span&gt;  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #2b91af&quot;&gt;Dictionary&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt;, &lt;span style=&quot;color: #2b91af&quot;&gt;AbstractAnimalBase&lt;/span&gt;&amp;gt; AnimalCache { &lt;span style=&quot;color: #0000ff&quot;&gt;get&lt;/span&gt;; &lt;span style=&quot;color: #0000ff&quot;&gt;set&lt;/span&gt;; }  &lt;li&gt;&amp;nbsp; &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;internal&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;void&lt;/span&gt; AddAnimalToCache(&lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt; type, &lt;span style=&quot;color: #2b91af&quot;&gt;AbstractAnimalBase&lt;/span&gt; animal)  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;if&lt;/span&gt; (AnimalCache == &lt;span style=&quot;color: #0000ff&quot;&gt;null&lt;/span&gt;)  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; AnimalCache = &lt;span style=&quot;color: #0000ff&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #2b91af&quot;&gt;Dictionary&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt;, &lt;span style=&quot;color: #2b91af&quot;&gt;AbstractAnimalBase&lt;/span&gt;&amp;gt;();  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; type = type.ToLower().Trim();  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;if&lt;/span&gt; (!AnimalCache.ContainsKey(type))  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li&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; AnimalCache.Add(type, animal);  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;else&lt;/span&gt;  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #2b91af&quot;&gt;Exception&lt;/span&gt;(&lt;span style=&quot;color: #2b91af&quot;&gt;String&lt;/span&gt;.Format(&lt;span style=&quot;color: #a31515&quot;&gt;&quot;Animal type {0} already exists&quot;&lt;/span&gt;, type));  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #2b91af&quot;&gt;AbstractAnimalBase&lt;/span&gt; GetAnimalFromCache(&lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt; type)  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;if&lt;/span&gt; (AnimalCache == &lt;span style=&quot;color: #0000ff&quot;&gt;null&lt;/span&gt;)  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li&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; AnimalCache = &lt;span style=&quot;color: #0000ff&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #2b91af&quot;&gt;Dictionary&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt;, &lt;span style=&quot;color: #2b91af&quot;&gt;AbstractAnimalBase&lt;/span&gt;&amp;gt;();  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li&gt;&amp;nbsp; &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; type = type.ToLower().Trim();  &lt;li&gt;&amp;nbsp; &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;if&lt;/span&gt; (!AnimalCache.ContainsKey(type))  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #2b91af&quot;&gt;Exception&lt;/span&gt;(&lt;span style=&quot;color: #2b91af&quot;&gt;String&lt;/span&gt;.Format(&lt;span style=&quot;color: #a31515&quot;&gt;&quot;Unknown animal type {0}&quot;&lt;/span&gt;, type));  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; AnimalCache[type];  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt; &lt;h1&gt;Dynamic Factories&lt;/h1&gt; &lt;p&gt;One thing that has always bothered me about the factory is having to add a class for what I want and then having to also modify the factory and maybe even an enum.&amp;nbsp; There has to be a way for classes to “self register” themselves with a factory…well, there is with the above code – the constructor of each subclassed animal can add itself to the factory.&amp;nbsp; Well, that’s great…but who is going to call the constructor for each of those sub-classes?&amp;nbsp; Too bad the base class can’t determine it’s subclasses…or, wait, it can, but indirectly – through reflection.&lt;/p&gt; &lt;p&gt;Couple words on reflection and creating a factory in this way – reflection is “slow” in general, so you’ll probably want to cache the objects that are created and you probably only want to discover your classes once – on start up or on first use of the factory.&amp;nbsp; Also, with this method, I’ve only used no-parameter constructors…and all the classes match that no-parameter constructor rule – probably ways around it but it will be a bit more coding to deal with that (i.e. it’s not as easy to do as with a normal factory).&amp;nbsp; And, while this may be a way to dynamically discover classes for your factory, it raises some security concerns as well so code accordingly.&amp;nbsp; So, use at your own risk basically.&lt;/p&gt; &lt;p&gt;Ok, enough with the legal warnings and notices.&amp;nbsp; On to the code…&lt;/p&gt; &lt;h2&gt;Brief Introduction to Reflection (as it pertains to Dynamic Factories)&lt;/h2&gt; &lt;p&gt;So, the first question is how do we find out what classes are within a file?&amp;nbsp; .Net actually makes this fairly simple…we have to load the assembly (i.e. dll or exe) into memory, then we can get all the types within that file.&amp;nbsp; Essentially the code to do this is:&lt;/p&gt; &lt;div style=&quot;padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px&quot; id=&quot;scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:cb560ba0-29aa-47e0-86f4-2aa592356365&quot; class=&quot;wlWriterSmartContent&quot;&gt; &lt;div style=&quot;border-bottom: #000080 1px solid; border-left: #000080 1px solid; font-family: &#39;Courier New&#39;, courier, monospace; color: #000; font-size: 10pt; border-top: #000080 1px solid; border-right: #000080 1px solid&quot;&gt; &lt;div style=&quot;padding-bottom: 2px; padding-left: 5px; padding-right: 5px; font-family: verdana, tahoma, arial, sans-serif; background: #000080; color: #fff; font-weight: bold; padding-top: 2px&quot;&gt;Code Snippet&lt;/div&gt; &lt;div style=&quot;background: #ddd; max-height: 300px; overflow: auto&quot;&gt; &lt;ol style=&quot;padding-bottom: 0px; margin: 0px 0px 0px 2em; padding-left: 5px; padding-right: 0px; background: #ffffff; padding-top: 0px&quot;&gt; &lt;li&gt;&lt;span style=&quot;color: #2b91af&quot;&gt;Assembly&lt;/span&gt; assembly = &lt;span style=&quot;color: #2b91af&quot;&gt;Assembly&lt;/span&gt;.LoadFrom(filename);  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&lt;span style=&quot;color: #2b91af&quot;&gt;Type&lt;/span&gt;[] types = assembly.GetTypes(); &lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;Where filename is the full path to an exe or dll that we want to inspect.&lt;/p&gt; &lt;h2&gt;Discovering Interested Types&lt;/h2&gt; &lt;p&gt;Next, we just iterate over all the types to see if they match what we’re looking for.&amp;nbsp; We’ve got to be careful here as a type could be an interface, an abstract class, or not even a class that we’re interested in.&amp;nbsp; For this, I’ve written a routine to verify a type is what I’m interested in.&lt;/p&gt; &lt;div style=&quot;padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px&quot; id=&quot;scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:5d72a54a-3f72-4984-ac72-0694ed229fe0&quot; class=&quot;wlWriterSmartContent&quot;&gt; &lt;div style=&quot;border-bottom: #000080 1px solid; border-left: #000080 1px solid; font-family: &#39;Courier New&#39;, courier, monospace; color: #000; font-size: 10pt; border-top: #000080 1px solid; border-right: #000080 1px solid&quot;&gt; &lt;div style=&quot;padding-bottom: 2px; padding-left: 5px; padding-right: 5px; font-family: verdana, tahoma, arial, sans-serif; background: #000080; color: #fff; font-weight: bold; padding-top: 2px&quot;&gt;Code Snippet&lt;/div&gt; &lt;div style=&quot;background: #ddd; max-height: 300px; overflow: auto&quot;&gt; &lt;ol style=&quot;padding-bottom: 0px; margin: 0px 0px 0px 2.5em; padding-left: 5px; padding-right: 0px; white-space: nowrap; background: #ffffff; padding-top: 0px&quot;&gt; &lt;li&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;bool&lt;/span&gt; IsValidAnimal(&lt;span style=&quot;color: #2b91af&quot;&gt;Type&lt;/span&gt; type, &lt;span style=&quot;color: #0000ff&quot;&gt;ref&lt;/span&gt; &lt;span style=&quot;color: #2b91af&quot;&gt;AbstractAnimalBase&lt;/span&gt; animal)  &lt;li style=&quot;background: #f3f3f3&quot;&gt;{  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #008000&quot;&gt;//is it a sub-class&lt;/span&gt;  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;if&lt;/span&gt; (type.BaseType != &lt;span style=&quot;color: #0000ff&quot;&gt;null&lt;/span&gt;)  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #008000&quot;&gt;//make sure it&#39;s not an interface&lt;/span&gt;  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;if&lt;/span&gt; (!type.IsInterface)  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #008000&quot;&gt;//is it a sub-class of what we&#39;re interested in&lt;/span&gt;  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;if&lt;/span&gt; (type.IsSubclassOf((&lt;span style=&quot;color: #0000ff&quot;&gt;typeof&lt;/span&gt;(&lt;span style=&quot;color: #2b91af&quot;&gt;AbstractAnimalBase&lt;/span&gt;))))  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #008000&quot;&gt;//make sure the type is a concrete type (i.e. not abstract)&lt;/span&gt;  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;if&lt;/span&gt; (!type.IsAbstract)  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li&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; &lt;span style=&quot;color: #0000ff&quot;&gt;try&lt;/span&gt;  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li&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; animal = (&lt;span style=&quot;color: #2b91af&quot;&gt;AbstractAnimalBase&lt;/span&gt;)type.InvokeMember(&lt;span style=&quot;color: #0000ff&quot;&gt;null&lt;/span&gt;, &lt;span style=&quot;color: #2b91af&quot;&gt;BindingFlags&lt;/span&gt;.CreateInstance, &lt;span style=&quot;color: #0000ff&quot;&gt;null&lt;/span&gt;, &lt;span style=&quot;color: #0000ff&quot;&gt;null&lt;/span&gt;, &lt;span style=&quot;color: #0000ff&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;object&lt;/span&gt;[] { });  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;true&lt;/span&gt;;  &lt;li&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; }  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;catch&lt;/span&gt; (&lt;span style=&quot;color: #2b91af&quot;&gt;Exception&lt;/span&gt; ex)  &lt;li&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; {  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #2b91af&quot;&gt;Exception&lt;/span&gt;(&lt;span style=&quot;color: #2b91af&quot;&gt;String&lt;/span&gt;.Format(&lt;span style=&quot;color: #a31515&quot;&gt;&quot;Failed to load {0} as a add on command from {1}&quot;&lt;/span&gt;, type.Name, type.AssemblyQualifiedName), ex);  &lt;li&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; }  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;false&lt;/span&gt;;  &lt;li&gt;} &lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;So, to put the loading all together into a single class…&lt;/p&gt; &lt;div style=&quot;padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px&quot; id=&quot;scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:0dc36f32-ad11-40ae-993c-7c286416c659&quot; class=&quot;wlWriterSmartContent&quot;&gt; &lt;div style=&quot;border-bottom: #000080 1px solid; border-left: #000080 1px solid; font-family: &#39;Courier New&#39;, courier, monospace; color: #000; font-size: 10pt; border-top: #000080 1px solid; border-right: #000080 1px solid&quot;&gt; &lt;div style=&quot;padding-bottom: 2px; padding-left: 5px; padding-right: 5px; font-family: verdana, tahoma, arial, sans-serif; background: #000080; color: #fff; font-weight: bold; padding-top: 2px&quot;&gt;AnimalLoader.cs&lt;/div&gt; &lt;div style=&quot;background: #ddd; max-height: 300px; overflow: auto&quot;&gt; &lt;ol style=&quot;padding-bottom: 0px; margin: 0px 0px 0px 2.5em; padding-left: 5px; padding-right: 0px; white-space: nowrap; background: #ffffff; padding-top: 0px&quot;&gt; &lt;li&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;using&lt;/span&gt; System;  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;using&lt;/span&gt; System.Collections.Generic;  &lt;li&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;using&lt;/span&gt; System.Reflection;  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp; &lt;li&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: #2b91af&quot;&gt;AnimalLoader&lt;/span&gt;  &lt;li style=&quot;background: #f3f3f3&quot;&gt;{  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #2b91af&quot;&gt;List&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #2b91af&quot;&gt;AbstractAnimalBase&lt;/span&gt;&amp;gt; LoadAnimals(&lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt; filename)  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #2b91af&quot;&gt;List&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #2b91af&quot;&gt;AbstractAnimalBase&lt;/span&gt;&amp;gt; animals = &lt;span style=&quot;color: #0000ff&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #2b91af&quot;&gt;List&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #2b91af&quot;&gt;AbstractAnimalBase&lt;/span&gt;&amp;gt;();  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #2b91af&quot;&gt;Assembly&lt;/span&gt; assembly = &lt;span style=&quot;color: #2b91af&quot;&gt;Assembly&lt;/span&gt;.LoadFrom(filename);  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #2b91af&quot;&gt;Type&lt;/span&gt;[] types = assembly.GetTypes();  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;foreach&lt;/span&gt; (&lt;span style=&quot;color: #2b91af&quot;&gt;Type&lt;/span&gt; type &lt;span style=&quot;color: #0000ff&quot;&gt;in&lt;/span&gt; types)  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #2b91af&quot;&gt;AbstractAnimalBase&lt;/span&gt; animal = &lt;span style=&quot;color: #0000ff&quot;&gt;null&lt;/span&gt;;  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;if&lt;/span&gt; (IsValidAnimal(type,&lt;span style=&quot;color: #0000ff&quot;&gt;ref&lt;/span&gt; animal))  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; animals.Add(animal);  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; animals;  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li&gt;&amp;nbsp; &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;bool&lt;/span&gt; IsValidAnimal(&lt;span style=&quot;color: #2b91af&quot;&gt;Type&lt;/span&gt; type, &lt;span style=&quot;color: #0000ff&quot;&gt;ref&lt;/span&gt; &lt;span style=&quot;color: #2b91af&quot;&gt;AbstractAnimalBase&lt;/span&gt; animal)  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #008000&quot;&gt;//is it a sub-class&lt;/span&gt;  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;if&lt;/span&gt; (type.BaseType != &lt;span style=&quot;color: #0000ff&quot;&gt;null&lt;/span&gt;)  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #008000&quot;&gt;//make sure it&#39;s not an interface&lt;/span&gt;  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;if&lt;/span&gt; (!type.IsInterface)  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #008000&quot;&gt;//is it a sub-class of what we&#39;re interested in&lt;/span&gt;  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;if&lt;/span&gt; (type.IsSubclassOf((&lt;span style=&quot;color: #0000ff&quot;&gt;typeof&lt;/span&gt;(&lt;span style=&quot;color: #2b91af&quot;&gt;AbstractAnimalBase&lt;/span&gt;))))  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li&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; &lt;span style=&quot;color: #008000&quot;&gt;//make sure the type is a concrete type (i.e. not abstract)&lt;/span&gt;  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;if&lt;/span&gt; (!type.IsAbstract)  &lt;li&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; {  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;try&lt;/span&gt;  &lt;li&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; {  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; animal = (&lt;span style=&quot;color: #2b91af&quot;&gt;AbstractAnimalBase&lt;/span&gt;)type.InvokeMember(&lt;span style=&quot;color: #0000ff&quot;&gt;null&lt;/span&gt;, &lt;span style=&quot;color: #2b91af&quot;&gt;BindingFlags&lt;/span&gt;.CreateInstance, &lt;span style=&quot;color: #0000ff&quot;&gt;null&lt;/span&gt;, &lt;span style=&quot;color: #0000ff&quot;&gt;null&lt;/span&gt;, &lt;span style=&quot;color: #0000ff&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;object&lt;/span&gt;[] { });  &lt;li&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; &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;true&lt;/span&gt;;  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li&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; &lt;span style=&quot;color: #0000ff&quot;&gt;catch&lt;/span&gt; (&lt;span style=&quot;color: #2b91af&quot;&gt;Exception&lt;/span&gt; ex)  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li&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; &lt;span style=&quot;color: #0000ff&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #2b91af&quot;&gt;Exception&lt;/span&gt;(&lt;span style=&quot;color: #2b91af&quot;&gt;String&lt;/span&gt;.Format(&lt;span style=&quot;color: #a31515&quot;&gt;&quot;Failed to load {0} as a add on command from {1}&quot;&lt;/span&gt;, type.Name, type.AssemblyQualifiedName), ex);  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li&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; }  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;false&lt;/span&gt;;  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li&gt;} &lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;Ok, so we can now load the animals that’re in a dll or exe, but how do we load them into our factory?&amp;nbsp; Need a key for each of the animals and also a way to load them before the factory is first used.&lt;/p&gt; &lt;h2&gt;Making the Abstract Class “Keyable”&lt;/h2&gt; &lt;p&gt;Well, we actually have a key in the AbstractAnimalBase class but it’s protected – let’s fix that and make it public so that the factory can access the keys (yes, it can be marked as internal instead as long as the factory and animal base class are in the same exe or dll).&amp;nbsp; So the new AbstractAnimalBase class is changed to:&lt;/p&gt; &lt;div style=&quot;padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px&quot; id=&quot;scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:71dff49e-b7f9-476e-8a31-b12ae149d0cc&quot; class=&quot;wlWriterSmartContent&quot;&gt; &lt;div style=&quot;border-bottom: #000080 1px solid; border-left: #000080 1px solid; font-family: &#39;Courier New&#39;, courier, monospace; color: #000; font-size: 10pt; border-top: #000080 1px solid; border-right: #000080 1px solid&quot;&gt; &lt;div style=&quot;padding-bottom: 2px; padding-left: 5px; padding-right: 5px; font-family: verdana, tahoma, arial, sans-serif; background: #000080; color: #fff; font-weight: bold; padding-top: 2px&quot;&gt;AbstractAnimalBase.cs&lt;/div&gt; &lt;div style=&quot;background: #ddd; max-height: 300px; overflow: auto&quot;&gt; &lt;ol style=&quot;padding-bottom: 0px; margin: 0px 0px 0px 2.5em; padding-left: 5px; padding-right: 0px; white-space: nowrap; background: #ffffff; padding-top: 0px&quot;&gt; &lt;li&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;abstract&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: #2b91af&quot;&gt;AbstractAnimalBase&lt;/span&gt;  &lt;li style=&quot;background: #f3f3f3&quot;&gt;{  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt; AnimalType { &lt;span style=&quot;color: #0000ff&quot;&gt;get&lt;/span&gt;; &lt;span style=&quot;color: #0000ff&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;set&lt;/span&gt;; }  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; AbstractAnimalBase(&lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt; type)  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; AnimalType = type;  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li&gt;&amp;nbsp; &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;void&lt;/span&gt; IntroduceSelf()  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.&lt;span style=&quot;color: #2b91af&quot;&gt;Console&lt;/span&gt;.WriteLine(IntroductionLine);  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.&lt;span style=&quot;color: #2b91af&quot;&gt;Console&lt;/span&gt;.WriteLine(Speak);  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.&lt;span style=&quot;color: #2b91af&quot;&gt;Console&lt;/span&gt;.WriteLine();  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;virtual&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt; IntroductionLine  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;get&lt;/span&gt;  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt; introLine = &lt;span style=&quot;color: #a31515&quot;&gt;&quot;Hello, I am a &quot;&lt;/span&gt; + AnimalType;  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; introLine;  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li&gt;&amp;nbsp; &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;abstract&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt; Speak  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;get&lt;/span&gt;;  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li style=&quot;background: #f3f3f3&quot;&gt;} &lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt; &lt;h2&gt;Dynamic Factory Class&lt;/h2&gt; &lt;p&gt;Now, to get that factory working.&amp;nbsp; What would be nice would be for the factory to load the add ins when it’s first used…well, it can – by using a static constructor.&lt;/p&gt; &lt;div style=&quot;padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px&quot; id=&quot;scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:174846d3-ad0b-4371-a631-481eae5bad92&quot; class=&quot;wlWriterSmartContent&quot;&gt; &lt;div style=&quot;border-bottom: #000080 1px solid; border-left: #000080 1px solid; font-family: &#39;Courier New&#39;, courier, monospace; color: #000; font-size: 10pt; border-top: #000080 1px solid; border-right: #000080 1px solid&quot;&gt; &lt;div style=&quot;padding-bottom: 2px; padding-left: 5px; padding-right: 5px; font-family: verdana, tahoma, arial, sans-serif; background: #000080; color: #fff; font-weight: bold; padding-top: 2px&quot;&gt;AnimalFactory.cs&lt;/div&gt; &lt;div style=&quot;background: #ddd; max-height: 300px; overflow: auto&quot;&gt; &lt;ol style=&quot;padding-bottom: 0px; margin: 0px 0px 0px 2.5em; padding-left: 5px; padding-right: 0px; white-space: nowrap; background: #ffffff; padding-top: 0px&quot;&gt; &lt;li&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: #2b91af&quot;&gt;AnimalFactory&lt;/span&gt;  &lt;li style=&quot;background: #f3f3f3&quot;&gt;{  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #2b91af&quot;&gt;Dictionary&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt;, &lt;span style=&quot;color: #2b91af&quot;&gt;AbstractAnimalBase&lt;/span&gt;&amp;gt; Animals { &lt;span style=&quot;color: #0000ff&quot;&gt;get&lt;/span&gt;; &lt;span style=&quot;color: #0000ff&quot;&gt;set&lt;/span&gt;; }  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;static&lt;/span&gt; AnimalFactory()  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Animals = &lt;span style=&quot;color: #0000ff&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #2b91af&quot;&gt;Dictionary&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt;, &lt;span style=&quot;color: #2b91af&quot;&gt;AbstractAnimalBase&lt;/span&gt;&amp;gt;();  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #2b91af&quot;&gt;List&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #2b91af&quot;&gt;AbstractAnimalBase&lt;/span&gt;&amp;gt; animals;  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt; filename=&lt;span style=&quot;color: #a31515&quot;&gt;&quot;Animals.dll&quot;&lt;/span&gt;;  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt; path=&lt;span style=&quot;color: #2b91af&quot;&gt;Assembly&lt;/span&gt;.GetExecutingAssembly().Location;  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; path=System.IO.&lt;span style=&quot;color: #2b91af&quot;&gt;Path&lt;/span&gt;.GetDirectoryName(path);  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt; fileToLoad=System.IO.&lt;span style=&quot;color: #2b91af&quot;&gt;Path&lt;/span&gt;.Combine(path,filename);  &lt;li&gt;&amp;nbsp; &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;try&lt;/span&gt;  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; animals = &lt;span style=&quot;color: #2b91af&quot;&gt;AnimalLoader&lt;/span&gt;.LoadAnimals(fileToLoad);  &lt;li&gt;&amp;nbsp; &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;foreach&lt;/span&gt; (&lt;span style=&quot;color: #2b91af&quot;&gt;AbstractAnimalBase&lt;/span&gt; animal &lt;span style=&quot;color: #0000ff&quot;&gt;in&lt;/span&gt; animals)  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt; animalType = animal.AnimalType.ToLower().Trim();  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;if&lt;/span&gt; (!Animals.ContainsKey(animalType))  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li&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; Animals.Add(animalType, animal);  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;else&lt;/span&gt;  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li&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; &lt;span style=&quot;color: #0000ff&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #2b91af&quot;&gt;Exception&lt;/span&gt;(&lt;span style=&quot;color: #2b91af&quot;&gt;String&lt;/span&gt;.Format(&lt;span style=&quot;color: #a31515&quot;&gt;&quot;Duplicate animal type {0} found&quot;&lt;/span&gt;, animalType));  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;catch&lt;/span&gt; (&lt;span style=&quot;color: #2b91af&quot;&gt;Exception&lt;/span&gt; ex)  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #2b91af&quot;&gt;Exception&lt;/span&gt;(&lt;span style=&quot;color: #2b91af&quot;&gt;String&lt;/span&gt;.Format(&lt;span style=&quot;color: #a31515&quot;&gt;&quot;There was a problem loading the assembly {0}&quot;&lt;/span&gt;, fileToLoad),ex);  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;For this factory, for demo purposes, I’ve set the filename to be a static dll named Animals.dll, which the static constructor will use to pass to the AnimalLoader – you’ll more than likely want to use something different, but, remember, static constructors cannot accept parameters so you’ll have to find another way or just loop through all dlls.&amp;nbsp; Also, this uses the current executing path – change as needed for your own purposes.&amp;nbsp; Really, not a lot here – animals are discovered and loaded by the AnimalLoader method, then the animal types and the animal are added to the static list of animals for the factory.&amp;nbsp; If you’ve been paying attention, yes, this is a cached factory at this point as reflection is slow.&lt;/p&gt; &lt;p&gt;Now, for getting the animals out of the factory.&lt;/p&gt; &lt;div style=&quot;padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px&quot; id=&quot;scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:df4fd24d-2ce7-481d-9e10-9664d581b921&quot; class=&quot;wlWriterSmartContent&quot;&gt; &lt;div style=&quot;border-bottom: #000080 1px solid; border-left: #000080 1px solid; font-family: &#39;Courier New&#39;, courier, monospace; color: #000; font-size: 10pt; border-top: #000080 1px solid; border-right: #000080 1px solid&quot;&gt; &lt;div style=&quot;padding-bottom: 2px; padding-left: 5px; padding-right: 5px; font-family: verdana, tahoma, arial, sans-serif; background: #000080; color: #fff; font-weight: bold; padding-top: 2px&quot;&gt;AnimalFactory.cs&lt;/div&gt; &lt;div style=&quot;background: #ddd; max-height: 300px; overflow: auto&quot;&gt; &lt;ol style=&quot;padding-bottom: 0px; margin: 0px 0px 0px 2.5em; padding-left: 5px; padding-right: 0px; white-space: nowrap; background: #ffffff; padding-top: 0px&quot;&gt; &lt;li&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #2b91af&quot;&gt;AbstractAnimalBase&lt;/span&gt; GetCachedAnimal(&lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt; type)  &lt;li style=&quot;background: #f3f3f3&quot;&gt;{  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; type=type.ToLower().Trim();  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;if&lt;/span&gt; (Animals.ContainsKey(type))  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; Animals[type];  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;else&lt;/span&gt;  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #2b91af&quot;&gt;Exception&lt;/span&gt;(&lt;span style=&quot;color: #2b91af&quot;&gt;String&lt;/span&gt;.Format(&lt;span style=&quot;color: #a31515&quot;&gt;&quot;Unknown animal type {0}&quot;&lt;/span&gt;, type));  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li style=&quot;background: #f3f3f3&quot;&gt;}  &lt;li&gt;&amp;nbsp; &lt;li style=&quot;background: #f3f3f3&quot;&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #2b91af&quot;&gt;AbstractAnimalBase&lt;/span&gt; GetAnimal(&lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt; type)  &lt;li&gt;{  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #2b91af&quot;&gt;AbstractAnimalBase&lt;/span&gt; cachedAnimal = GetCachedAnimal(type);  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #2b91af&quot;&gt;Type&lt;/span&gt; animalAssemblyType = cachedAnimal.GetType();  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #2b91af&quot;&gt;AbstractAnimalBase&lt;/span&gt; animal = (&lt;span style=&quot;color: #2b91af&quot;&gt;AbstractAnimalBase&lt;/span&gt;)animalAssemblyType.Assembly.CreateInstance(animalAssemblyType.FullName);  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; animal;  &lt;li&gt;} &lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;Two things to notice here, there’s a method to get a cached animal as well as creating a new one based on the cached version.&amp;nbsp; I’ve supplied both just to show how to get a new animal from a cached version (this could also work for a normal cached factory as well as one using reflection to dynamically add classes).&lt;/p&gt; &lt;h2&gt;Discovering what is available&lt;/h2&gt; &lt;p&gt;And, that pretty much wraps up the factories and how to load classes dynamically.&amp;nbsp; What, you want to know what types are available to show to your UI?&amp;nbsp; Ok, here’s how you do that (requires “using System.Linq” namespace to be added thanks to the ToList extension method)…&lt;/p&gt; &lt;div style=&quot;padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px&quot; id=&quot;scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:a002e3ac-b4c0-408a-b6a4-206397bed864&quot; class=&quot;wlWriterSmartContent&quot;&gt; &lt;div style=&quot;border-bottom: #000080 1px solid; border-left: #000080 1px solid; font-family: &#39;Courier New&#39;, courier, monospace; color: #000; font-size: 10pt; border-top: #000080 1px solid; border-right: #000080 1px solid&quot;&gt; &lt;div style=&quot;padding-bottom: 2px; padding-left: 5px; padding-right: 5px; font-family: verdana, tahoma, arial, sans-serif; background: #000080; color: #fff; font-weight: bold; padding-top: 2px&quot;&gt;AnimalFactory.cs&lt;/div&gt; &lt;div style=&quot;background: #ddd; max-height: 300px; overflow: auto&quot;&gt; &lt;ol style=&quot;padding-bottom: 0px; margin: 0px 0px 0px 2em; padding-left: 5px; padding-right: 0px; white-space: nowrap; background: #ffffff; padding-top: 0px&quot;&gt; &lt;li&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #2b91af&quot;&gt;List&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt;&amp;gt; GetAnimalTypes()  &lt;li style=&quot;background: #f3f3f3&quot;&gt;{  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; Animals.Keys.ToList&amp;lt;&lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt;&amp;gt;();  &lt;li style=&quot;background: #f3f3f3&quot;&gt;} &lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt; &lt;h2&gt;Dynamic Cached Factory Code&lt;/h2&gt; &lt;p&gt;Now, for all the dynamic cached factory code.&lt;/p&gt; &lt;div style=&quot;padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px&quot; id=&quot;scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:be998093-1ad3-44c3-b83c-f0aaaf3b63e1&quot; class=&quot;wlWriterSmartContent&quot;&gt; &lt;div style=&quot;border-bottom: #000080 1px solid; border-left: #000080 1px solid; font-family: &#39;Courier New&#39;, courier, monospace; color: #000; font-size: 10pt; border-top: #000080 1px solid; border-right: #000080 1px solid&quot;&gt; &lt;div style=&quot;padding-bottom: 2px; padding-left: 5px; padding-right: 5px; font-family: verdana, tahoma, arial, sans-serif; background: #000080; color: #fff; font-weight: bold; padding-top: 2px&quot;&gt;AbstractAnimalBase&lt;/div&gt; &lt;div style=&quot;background: #ddd; max-height: 300px; overflow: auto&quot;&gt; &lt;ol style=&quot;padding-bottom: 0px; margin: 0px 0px 0px 2.5em; padding-left: 5px; padding-right: 0px; white-space: nowrap; background: #ffffff; padding-top: 0px&quot;&gt; &lt;li&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;using&lt;/span&gt; System;  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp; &lt;li&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;abstract&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: #2b91af&quot;&gt;AbstractAnimalBase&lt;/span&gt;  &lt;li style=&quot;background: #f3f3f3&quot;&gt;{  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt; AnimalType { &lt;span style=&quot;color: #0000ff&quot;&gt;get&lt;/span&gt;; &lt;span style=&quot;color: #0000ff&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;set&lt;/span&gt;; }  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; AbstractAnimalBase(&lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt; type)  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; AnimalType = type;  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li&gt;&amp;nbsp; &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;void&lt;/span&gt; IntroduceSelf()  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.&lt;span style=&quot;color: #2b91af&quot;&gt;Console&lt;/span&gt;.WriteLine(IntroductionLine);  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.&lt;span style=&quot;color: #2b91af&quot;&gt;Console&lt;/span&gt;.WriteLine(Speak);  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.&lt;span style=&quot;color: #2b91af&quot;&gt;Console&lt;/span&gt;.WriteLine();  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;virtual&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt; IntroductionLine  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;get&lt;/span&gt;  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt; introLine = &lt;span style=&quot;color: #a31515&quot;&gt;&quot;Hello, I am a &quot;&lt;/span&gt; + AnimalType;  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; introLine;  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li&gt;&amp;nbsp; &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;abstract&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt; Speak  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;get&lt;/span&gt;;  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li style=&quot;background: #f3f3f3&quot;&gt;} &lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;div style=&quot;padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px&quot; id=&quot;scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:74d13f8c-3d0e-481b-b281-4bb3e14ea41b&quot; class=&quot;wlWriterSmartContent&quot;&gt; &lt;div style=&quot;border-bottom: #000080 1px solid; border-left: #000080 1px solid; font-family: &#39;Courier New&#39;, courier, monospace; color: #000; font-size: 10pt; border-top: #000080 1px solid; border-right: #000080 1px solid&quot;&gt; &lt;div style=&quot;padding-bottom: 2px; padding-left: 5px; padding-right: 5px; font-family: verdana, tahoma, arial, sans-serif; background: #000080; color: #fff; font-weight: bold; padding-top: 2px&quot;&gt;Dog.cs&lt;/div&gt; &lt;div style=&quot;background: #ddd; max-height: 300px; overflow: auto&quot;&gt; &lt;ol style=&quot;padding-bottom: 0px; margin: 0px 0px 0px 2.5em; padding-left: 5px; padding-right: 0px; white-space: nowrap; background: #ffffff; padding-top: 0px&quot;&gt; &lt;li&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;using&lt;/span&gt; System;  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp; &lt;li&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: #2b91af&quot;&gt;Dog&lt;/span&gt; : &lt;span style=&quot;color: #2b91af&quot;&gt;AbstractAnimalBase&lt;/span&gt;  &lt;li style=&quot;background: #f3f3f3&quot;&gt;{  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; Dog()  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : &lt;span style=&quot;color: #0000ff&quot;&gt;base&lt;/span&gt;(&lt;span style=&quot;color: #a31515&quot;&gt;&quot;Dog&quot;&lt;/span&gt;)  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li&gt;&amp;nbsp; &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;override&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt; Speak  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;get&lt;/span&gt; { &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #a31515&quot;&gt;&quot;Woof&quot;&lt;/span&gt;; }  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li style=&quot;background: #f3f3f3&quot;&gt;} &lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;div style=&quot;padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px&quot; id=&quot;scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:2e500413-35f2-488b-a4f8-f014949f12b8&quot; class=&quot;wlWriterSmartContent&quot;&gt; &lt;div style=&quot;border-bottom: #000080 1px solid; border-left: #000080 1px solid; font-family: &#39;Courier New&#39;, courier, monospace; color: #000; font-size: 10pt; border-top: #000080 1px solid; border-right: #000080 1px solid&quot;&gt; &lt;div style=&quot;padding-bottom: 2px; padding-left: 5px; padding-right: 5px; font-family: verdana, tahoma, arial, sans-serif; background: #000080; color: #fff; font-weight: bold; padding-top: 2px&quot;&gt;Cat.cs&lt;/div&gt; &lt;div style=&quot;background: #ddd; max-height: 300px; overflow: auto&quot;&gt; &lt;ol style=&quot;padding-bottom: 0px; margin: 0px 0px 0px 2.5em; padding-left: 5px; padding-right: 0px; white-space: nowrap; background: #ffffff; padding-top: 0px&quot;&gt; &lt;li&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;using&lt;/span&gt; System;  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp; &lt;li&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: #2b91af&quot;&gt;Cat&lt;/span&gt; : &lt;span style=&quot;color: #2b91af&quot;&gt;AbstractAnimalBase&lt;/span&gt;  &lt;li style=&quot;background: #f3f3f3&quot;&gt;{  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; Cat()  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : &lt;span style=&quot;color: #0000ff&quot;&gt;base&lt;/span&gt;(&lt;span style=&quot;color: #a31515&quot;&gt;&quot;Cat&quot;&lt;/span&gt;)  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li&gt;&amp;nbsp; &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;override&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt; Speak  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;get&lt;/span&gt; { &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #a31515&quot;&gt;&quot;Meow&quot;&lt;/span&gt;; }  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li style=&quot;background: #f3f3f3&quot;&gt;} &lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;div style=&quot;padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px&quot; id=&quot;scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:cf46921c-9370-4d5b-82be-df9fc7f1dbbb&quot; class=&quot;wlWriterSmartContent&quot;&gt; &lt;div style=&quot;border-bottom: #000080 1px solid; border-left: #000080 1px solid; font-family: &#39;Courier New&#39;, courier, monospace; color: #000; font-size: 10pt; border-top: #000080 1px solid; border-right: #000080 1px solid&quot;&gt; &lt;div style=&quot;padding-bottom: 2px; padding-left: 5px; padding-right: 5px; font-family: verdana, tahoma, arial, sans-serif; background: #000080; color: #fff; font-weight: bold; padding-top: 2px&quot;&gt;Pig.cs&lt;/div&gt; &lt;div style=&quot;background: #ddd; max-height: 300px; overflow: auto&quot;&gt; &lt;ol style=&quot;padding-bottom: 0px; margin: 0px 0px 0px 2.5em; padding-left: 5px; padding-right: 0px; white-space: nowrap; background: #ffffff; padding-top: 0px&quot;&gt; &lt;li&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;using&lt;/span&gt; System;  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp; &lt;li&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: #2b91af&quot;&gt;Pig&lt;/span&gt; : &lt;span style=&quot;color: #2b91af&quot;&gt;AbstractAnimalBase&lt;/span&gt;  &lt;li style=&quot;background: #f3f3f3&quot;&gt;{  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; Pig()  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : &lt;span style=&quot;color: #0000ff&quot;&gt;base&lt;/span&gt;(&lt;span style=&quot;color: #a31515&quot;&gt;&quot;Pig&quot;&lt;/span&gt;)  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li&gt;&amp;nbsp; &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;override&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt; Speak  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;get&lt;/span&gt; { &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #a31515&quot;&gt;&quot;Oink&quot;&lt;/span&gt;; }  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li style=&quot;background: #f3f3f3&quot;&gt;} &lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;div style=&quot;padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px&quot; id=&quot;scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:ae0f3772-414e-4955-99c9-329ee1e6a620&quot; class=&quot;wlWriterSmartContent&quot;&gt; &lt;div style=&quot;border-bottom: #000080 1px solid; border-left: #000080 1px solid; font-family: &#39;Courier New&#39;, courier, monospace; color: #000; font-size: 10pt; border-top: #000080 1px solid; border-right: #000080 1px solid&quot;&gt; &lt;div style=&quot;padding-bottom: 2px; padding-left: 5px; padding-right: 5px; font-family: verdana, tahoma, arial, sans-serif; background: #000080; color: #fff; font-weight: bold; padding-top: 2px&quot;&gt;AnimalLoader.cs&lt;/div&gt; &lt;div style=&quot;background: #ddd; max-height: 300px; overflow: auto&quot;&gt; &lt;ol style=&quot;padding-bottom: 0px; margin: 0px 0px 0px 2.5em; padding-left: 5px; padding-right: 0px; white-space: nowrap; background: #ffffff; padding-top: 0px&quot;&gt; &lt;li&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;using&lt;/span&gt; System;  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;using&lt;/span&gt; System.Collections.Generic;  &lt;li&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;using&lt;/span&gt; System.Reflection;  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp; &lt;li&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: #2b91af&quot;&gt;AnimalLoader&lt;/span&gt;  &lt;li style=&quot;background: #f3f3f3&quot;&gt;{  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #2b91af&quot;&gt;List&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #2b91af&quot;&gt;AbstractAnimalBase&lt;/span&gt;&amp;gt; LoadAnimals(&lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt; filename)  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #2b91af&quot;&gt;List&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #2b91af&quot;&gt;AbstractAnimalBase&lt;/span&gt;&amp;gt; animals = &lt;span style=&quot;color: #0000ff&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #2b91af&quot;&gt;List&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #2b91af&quot;&gt;AbstractAnimalBase&lt;/span&gt;&amp;gt;();  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #2b91af&quot;&gt;Assembly&lt;/span&gt; assembly = &lt;span style=&quot;color: #2b91af&quot;&gt;Assembly&lt;/span&gt;.LoadFrom(filename);  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #2b91af&quot;&gt;Type&lt;/span&gt;[] types = assembly.GetTypes();  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;foreach&lt;/span&gt; (&lt;span style=&quot;color: #2b91af&quot;&gt;Type&lt;/span&gt; type &lt;span style=&quot;color: #0000ff&quot;&gt;in&lt;/span&gt; types)  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #2b91af&quot;&gt;AbstractAnimalBase&lt;/span&gt; animal = &lt;span style=&quot;color: #0000ff&quot;&gt;null&lt;/span&gt;;  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;if&lt;/span&gt; (IsValidAnimal(type, &lt;span style=&quot;color: #0000ff&quot;&gt;ref&lt;/span&gt; animal))  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; animals.Add(animal);  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; animals;  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li&gt;&amp;nbsp; &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;bool&lt;/span&gt; IsValidAnimal(&lt;span style=&quot;color: #2b91af&quot;&gt;Type&lt;/span&gt; type, &lt;span style=&quot;color: #0000ff&quot;&gt;ref&lt;/span&gt; &lt;span style=&quot;color: #2b91af&quot;&gt;AbstractAnimalBase&lt;/span&gt; animal)  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #008000&quot;&gt;//is it a sub-class&lt;/span&gt;  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;if&lt;/span&gt; (type.BaseType != &lt;span style=&quot;color: #0000ff&quot;&gt;null&lt;/span&gt;)  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #008000&quot;&gt;//make sure it&#39;s not an interface&lt;/span&gt;  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;if&lt;/span&gt; (!type.IsInterface)  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #008000&quot;&gt;//is it a sub-class of what we&#39;re interested in&lt;/span&gt;  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;if&lt;/span&gt; (type.IsSubclassOf((&lt;span style=&quot;color: #0000ff&quot;&gt;typeof&lt;/span&gt;(&lt;span style=&quot;color: #2b91af&quot;&gt;AbstractAnimalBase&lt;/span&gt;))))  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li&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; &lt;span style=&quot;color: #008000&quot;&gt;//make sure the type is a concrete type (i.e. not abstract)&lt;/span&gt;  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;if&lt;/span&gt; (!type.IsAbstract)  &lt;li&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; {  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;try&lt;/span&gt;  &lt;li&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; {  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; animal = (&lt;span style=&quot;color: #2b91af&quot;&gt;AbstractAnimalBase&lt;/span&gt;)type.InvokeMember(&lt;span style=&quot;color: #0000ff&quot;&gt;null&lt;/span&gt;, &lt;span style=&quot;color: #2b91af&quot;&gt;BindingFlags&lt;/span&gt;.CreateInstance, &lt;span style=&quot;color: #0000ff&quot;&gt;null&lt;/span&gt;, &lt;span style=&quot;color: #0000ff&quot;&gt;null&lt;/span&gt;, &lt;span style=&quot;color: #0000ff&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;object&lt;/span&gt;[] { });  &lt;li&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; &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;true&lt;/span&gt;;  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li&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; &lt;span style=&quot;color: #0000ff&quot;&gt;catch&lt;/span&gt; (&lt;span style=&quot;color: #2b91af&quot;&gt;Exception&lt;/span&gt; ex)  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li&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; &lt;span style=&quot;color: #0000ff&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #2b91af&quot;&gt;Exception&lt;/span&gt;(&lt;span style=&quot;color: #2b91af&quot;&gt;String&lt;/span&gt;.Format(&lt;span style=&quot;color: #a31515&quot;&gt;&quot;Failed to load {0} as a add on command from {1}&quot;&lt;/span&gt;, type.Name, type.AssemblyQualifiedName), ex);  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li&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; }  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;false&lt;/span&gt;;  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li&gt;} &lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;div style=&quot;padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px&quot; id=&quot;scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:ba3168bf-4888-43ac-906f-8383047e0507&quot; class=&quot;wlWriterSmartContent&quot;&gt; &lt;div style=&quot;border-bottom: #000080 1px solid; border-left: #000080 1px solid; font-family: &#39;Courier New&#39;, courier, monospace; color: #000; font-size: 10pt; border-top: #000080 1px solid; border-right: #000080 1px solid&quot;&gt; &lt;div style=&quot;padding-bottom: 2px; padding-left: 5px; padding-right: 5px; font-family: verdana, tahoma, arial, sans-serif; background: #000080; color: #fff; font-weight: bold; padding-top: 2px&quot;&gt;AnimalFactory.cs&lt;/div&gt; &lt;div style=&quot;background: #ddd; max-height: 300px; overflow: auto&quot;&gt; &lt;ol style=&quot;padding-bottom: 0px; margin: 0px 0px 0px 2.5em; padding-left: 5px; padding-right: 0px; white-space: nowrap; background: #ffffff; padding-top: 0px&quot;&gt; &lt;li&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;using&lt;/span&gt; System;  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;using&lt;/span&gt; System.Collections.Generic;  &lt;li&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;using&lt;/span&gt; System.Reflection;  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;using&lt;/span&gt; System.Linq;  &lt;li&gt;&amp;nbsp; &lt;li style=&quot;background: #f3f3f3&quot;&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: #2b91af&quot;&gt;AnimalFactory&lt;/span&gt;  &lt;li&gt;{  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #2b91af&quot;&gt;Dictionary&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt;, &lt;span style=&quot;color: #2b91af&quot;&gt;AbstractAnimalBase&lt;/span&gt;&amp;gt; Animals { &lt;span style=&quot;color: #0000ff&quot;&gt;get&lt;/span&gt;; &lt;span style=&quot;color: #0000ff&quot;&gt;set&lt;/span&gt;; }  &lt;li&gt;&amp;nbsp; &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;static&lt;/span&gt; AnimalFactory()  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Animals = &lt;span style=&quot;color: #0000ff&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #2b91af&quot;&gt;Dictionary&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt;, &lt;span style=&quot;color: #2b91af&quot;&gt;AbstractAnimalBase&lt;/span&gt;&amp;gt;();  &lt;li&gt;&amp;nbsp; &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #2b91af&quot;&gt;List&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #2b91af&quot;&gt;AbstractAnimalBase&lt;/span&gt;&amp;gt; animals;  &lt;li&gt;&amp;nbsp; &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt; filename = &lt;span style=&quot;color: #a31515&quot;&gt;&quot;Animals.dll&quot;&lt;/span&gt;;  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt; path = &lt;span style=&quot;color: #2b91af&quot;&gt;Assembly&lt;/span&gt;.GetExecutingAssembly().Location;  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; path = System.IO.&lt;span style=&quot;color: #2b91af&quot;&gt;Path&lt;/span&gt;.GetDirectoryName(path);  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt; fileToLoad = System.IO.&lt;span style=&quot;color: #2b91af&quot;&gt;Path&lt;/span&gt;.Combine(path, filename);  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;try&lt;/span&gt;  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; animals = &lt;span style=&quot;color: #2b91af&quot;&gt;AnimalLoader&lt;/span&gt;.LoadAnimals(fileToLoad);  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;foreach&lt;/span&gt; (&lt;span style=&quot;color: #2b91af&quot;&gt;AbstractAnimalBase&lt;/span&gt; animal &lt;span style=&quot;color: #0000ff&quot;&gt;in&lt;/span&gt; animals)  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt; animalType = animal.AnimalType.ToLower().Trim();  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;if&lt;/span&gt; (!Animals.ContainsKey(animalType))  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Animals.Add(animalType, animal);  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;else&lt;/span&gt;  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #2b91af&quot;&gt;Exception&lt;/span&gt;(&lt;span style=&quot;color: #2b91af&quot;&gt;String&lt;/span&gt;.Format(&lt;span style=&quot;color: #a31515&quot;&gt;&quot;Duplicate animal type {0} found&quot;&lt;/span&gt;, animalType));  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;catch&lt;/span&gt; (&lt;span style=&quot;color: #2b91af&quot;&gt;Exception&lt;/span&gt; ex)  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #2b91af&quot;&gt;Exception&lt;/span&gt;(&lt;span style=&quot;color: #2b91af&quot;&gt;String&lt;/span&gt;.Format(&lt;span style=&quot;color: #a31515&quot;&gt;&quot;There was a problem loading the assembly {0}&quot;&lt;/span&gt;, fileToLoad), ex);  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li&gt;&amp;nbsp; &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #2b91af&quot;&gt;AbstractAnimalBase&lt;/span&gt; GetCachedAnimal(&lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt; type)  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; type = type.ToLower().Trim();  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;if&lt;/span&gt; (Animals.ContainsKey(type))  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; Animals[type];  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;else&lt;/span&gt;  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #2b91af&quot;&gt;Exception&lt;/span&gt;(&lt;span style=&quot;color: #2b91af&quot;&gt;String&lt;/span&gt;.Format(&lt;span style=&quot;color: #a31515&quot;&gt;&quot;Unknown animal type {0}&quot;&lt;/span&gt;, type));  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #2b91af&quot;&gt;AbstractAnimalBase&lt;/span&gt; GetAnimal(&lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt; type)  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #2b91af&quot;&gt;AbstractAnimalBase&lt;/span&gt; cachedAnimal = GetCachedAnimal(type);  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #2b91af&quot;&gt;Type&lt;/span&gt; animalAssemblyType = cachedAnimal.GetType();  &lt;li&gt;&amp;nbsp; &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #2b91af&quot;&gt;AbstractAnimalBase&lt;/span&gt; animal = (&lt;span style=&quot;color: #2b91af&quot;&gt;AbstractAnimalBase&lt;/span&gt;)animalAssemblyType.Assembly.CreateInstance(animalAssemblyType.FullName);  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; animal;  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li&gt;&amp;nbsp; &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #2b91af&quot;&gt;List&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt;&amp;gt; GetAnimalTypes()  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li style=&quot;background: #f3f3f3&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; Animals.Keys.ToList&amp;lt;&lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt;&amp;gt;();  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li style=&quot;background: #f3f3f3&quot;&gt;} &lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;  </content><link rel='replies' type='application/atom+xml' href='http://rhale78.blogspot.com/feeds/3618296027688505691/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://rhale78.blogspot.com/2011/07/factories-in-c-basic-cached-and-dynamic.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/270091469191232126/posts/default/3618296027688505691'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/270091469191232126/posts/default/3618296027688505691'/><link rel='alternate' type='text/html' href='http://rhale78.blogspot.com/2011/07/factories-in-c-basic-cached-and-dynamic.html' title='Factories in C#-Basic, Cached, and Dynamic'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/09185478558704427023</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-270091469191232126.post-686783710732331297</id><published>2011-05-31T22:19:00.002-04:00</published><updated>2015-06-14T19:10:28.196-04:00</updated><category scheme="http://www.blogger.com/atom/ns#" term=".Net 4.0"/><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="ExpressRecipe"/><category scheme="http://www.blogger.com/atom/ns#" term="WCF"/><title type='text'>Trial and Error–WCF Services Part 1</title><content type='html'>&lt;iframe align=&quot;left&quot; frameborder=&quot;0&quot; marginheight=&quot;0&quot; marginwidth=&quot;0&quot; scrolling=&quot;no&quot; src=&quot;http://rcm-na.amazon.com/e/cm?t=randsblog-20&amp;amp;o=1&amp;amp;p=8&amp;amp;l=bpl&amp;amp;asins=0596805489&amp;amp;fc1=000000&amp;amp;IS2=1&amp;amp;lt1=_blank&amp;amp;m=amazon&amp;amp;lc1=0000FF&amp;amp;bc1=000000&amp;amp;bg1=FFFFFF&amp;amp;f=ifr&quot; style=&quot;align: left; height: 245px; padding-right: 10px; padding-top: 5px; width: 131px;&quot;&gt;&lt;/iframe&gt;Decided a while ago that I would teach myself WCF (Windows Communication Framework) services.&amp;nbsp; Saw the book,&amp;nbsp; Programming WCF Services by Juval Lowy (ISBN 978-0-596-80548-7), at one of the local bookstores and decided to pick it up.&amp;nbsp; While the book is a good read, after the first chapter I was like “going to need to take notes to figure this out.”&amp;nbsp; Well, instead of doing that, I figured I’d start on a project I’ve been working on (ExpressRecipe) – the hard way – via trial and error.&amp;nbsp; Hopefully my pain will help someone else out there…&lt;br /&gt;
I wanted to start out with something simple first – being able to get a host running and then get the description (also known as the WSDL) of the service through a web browser.&amp;nbsp; To make things simple, I started out with a console app for the host in VS 2010.&amp;nbsp; I created a separate project under the same solution to hold the WCF service itself.&lt;br /&gt;
First minor sticking point – the WCF reference is not automatically included so that must be included if you’re expecting to use either the host or any of the service attributes.&amp;nbsp; So, be sure to add System.ServiceModel to all the projects that will be using WCF features.&amp;nbsp; Be sure to include the using statement for that reference as well…&lt;br /&gt;
My first task was to create a simple interface that will be the contract for the service.&amp;nbsp; I started out with a “user” contract that allows the client to create a new user with a first name, last name, username, and password as simple strings.&amp;nbsp; So, the interface looks like:&lt;br /&gt;
&lt;div class=&quot;wlWriterEditableSmartContent&quot; id=&quot;scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:2e6cacc0-2cf0-4d94-b942-3614bf4bb226&quot; style=&quot;display: inline; float: none; margin: 0px; padding: 0px;&quot;&gt;
&lt;div style=&quot;border: 1px solid rgb(0, 0, 128); color: black; font-family: &amp;quot;Courier New&amp;quot;, Courier, Monospace; font-size: 10pt;&quot;&gt;
&lt;div style=&quot;background: rgb(0, 0, 128); color: white; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px;&quot;&gt;
Code Snippet&lt;/div&gt;
&lt;div style=&quot;background: rgb(221, 221, 221); max-height: 300px; overflow: auto;&quot;&gt;
&lt;ol style=&quot;background: rgb(255, 255, 255); margin: 0px 0px 0px 2.5em; padding: 0px 0px 0px 5px; white-space: nowrap;&quot;&gt;
&lt;li&gt;&lt;span style=&quot;color: blue;&quot;&gt;using&lt;/span&gt; System;&lt;/li&gt;
&lt;li style=&quot;background: rgb(243, 243, 243);&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;using&lt;/span&gt; System.Collections.Generic;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;color: blue;&quot;&gt;using&lt;/span&gt; System.Linq;&lt;/li&gt;
&lt;li style=&quot;background: rgb(243, 243, 243);&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;using&lt;/span&gt; System.Text;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;color: blue;&quot;&gt;using&lt;/span&gt; System.ServiceModel;&lt;/li&gt;
&lt;li style=&quot;background: rgb(243, 243, 243);&quot;&gt;&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;color: blue;&quot;&gt;namespace&lt;/span&gt; ExpressRecipeWCFLibrary&lt;/li&gt;
&lt;li style=&quot;background: rgb(243, 243, 243);&quot;&gt;{&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[&lt;span style=&quot;color: #2b91af;&quot;&gt;ServiceContract&lt;/span&gt;]&lt;/li&gt;
&lt;li style=&quot;background: rgb(243, 243, 243);&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;interface&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;IExpressRecipeUserContract&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/li&gt;
&lt;li style=&quot;background: rgb(243, 243, 243);&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[&lt;span style=&quot;color: #2b91af;&quot;&gt;OperationContract&lt;/span&gt;]&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; AddUser(&lt;span style=&quot;color: blue;&quot;&gt;string&lt;/span&gt; firstName, &lt;span style=&quot;color: blue;&quot;&gt;string&lt;/span&gt; lastName, &lt;span style=&quot;color: blue;&quot;&gt;string&lt;/span&gt; username, &lt;span style=&quot;color: blue;&quot;&gt;string&lt;/span&gt; password);&lt;/li&gt;
&lt;li style=&quot;background: rgb(243, 243, 243);&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/li&gt;
&lt;li&gt;}&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
First things you’ll notice that’s difference than a normal interface are the ServiceContract and OperationContract attributes.&amp;nbsp; In their simple forms, the service contract is placed on the interface itself.&amp;nbsp; The operation contract is placed on all the methods you want the host to expose to the client.&amp;nbsp; Only one method here so the operation contract is specified only once.&amp;nbsp; One thing of note – according to the book and the code they showed for the attributes, the attributes shown here are not inheritable – so they’ll need to be reapplied if this interface is subclassed [subinterfaced?]…they will be applied to a class that implements them though.&lt;br /&gt;
Ok, interface is pretty simple…next – the implementation of the interface.&lt;br /&gt;
&lt;div class=&quot;wlWriterEditableSmartContent&quot; id=&quot;scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:dda6c2b8-5c59-4dbb-8869-b18267e6b71a&quot; style=&quot;display: inline; float: none; margin: 0px; padding: 0px;&quot;&gt;
&lt;div style=&quot;border: 1px solid rgb(0, 0, 128); color: black; font-family: &amp;quot;Courier New&amp;quot;, Courier, Monospace; font-size: 10pt;&quot;&gt;
&lt;div style=&quot;background: rgb(0, 0, 128); color: white; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px;&quot;&gt;
Code Snippet&lt;/div&gt;
&lt;div style=&quot;background: rgb(221, 221, 221); max-height: 500px; overflow: auto;&quot;&gt;
&lt;ol style=&quot;background: rgb(255, 255, 255); margin: 0px 0px 0px 2.5em; padding: 0px 0px 0px 5px; white-space: nowrap;&quot;&gt;
&lt;li&gt;&lt;span style=&quot;color: blue;&quot;&gt;using&lt;/span&gt; System;&lt;/li&gt;
&lt;li style=&quot;background: rgb(243, 243, 243);&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;using&lt;/span&gt; System.Collections.Generic;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;color: blue;&quot;&gt;using&lt;/span&gt; System.Linq;&lt;/li&gt;
&lt;li style=&quot;background: rgb(243, 243, 243);&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;using&lt;/span&gt; System.Text;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&lt;/li&gt;
&lt;li style=&quot;background: rgb(243, 243, 243);&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;namespace&lt;/span&gt; ExpressRecipeWCFLibrary&lt;/li&gt;
&lt;li&gt;{&lt;/li&gt;
&lt;li style=&quot;background: rgb(243, 243, 243);&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;UserService&lt;/span&gt;:&lt;span style=&quot;color: #2b91af;&quot;&gt;IExpressRecipeUserContract&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/li&gt;
&lt;li style=&quot;background: rgb(243, 243, 243);&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;#region&lt;/span&gt; IExpressRecipeUserContract Members&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&lt;/li&gt;
&lt;li style=&quot;background: rgb(243, 243, 243);&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; AddUser(&lt;span style=&quot;color: blue;&quot;&gt;string&lt;/span&gt; firstName, &lt;span style=&quot;color: blue;&quot;&gt;string&lt;/span&gt; lastName, &lt;span style=&quot;color: blue;&quot;&gt;string&lt;/span&gt; username, &lt;span style=&quot;color: blue;&quot;&gt;string&lt;/span&gt; password)&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/li&gt;
&lt;li style=&quot;background: rgb(243, 243, 243);&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;System.&lt;span style=&quot;color: #2b91af;&quot;&gt;Console&lt;/span&gt;.WriteLine(&lt;span style=&quot;color: #2b91af;&quot;&gt;String&lt;/span&gt;.Format(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;{0} {1} {2} {3}&quot;&lt;/span&gt;, firstName, lastName, username, password));&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/li&gt;
&lt;li style=&quot;background: rgb(243, 243, 243);&quot;&gt;&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;#endregion&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;background: rgb(243, 243, 243);&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/li&gt;
&lt;li&gt;}&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
Well, actually, nothing surprising here at all – simple implementation of a normal interface…not even a mention of the System.ServiceModel reference in the usings.&amp;nbsp; Well, that’s nice and fairly easy to do…just add the ServiceContract and OperationsContract to the interface and everything else is “business as usual.”&amp;nbsp; [note that interfaces are used here – while it is recommended to use an interface and add the attributes to that, nothing prevents you from adding them to the class itself – but, the design principle applies – “program to an interface, not an implementation” so try to use an interface if at all possible].&lt;br /&gt;
The operations I wanted exposed as a service are done so now it’s time for the host.&lt;br /&gt;
In the console Program.cs file, I created a new ServiceHost and passed it the type of my UserService class (notice not the interface but the class itself).&amp;nbsp; I also decided, for debugging purposes, to attach event handlers to each of the events raised by the host.&amp;nbsp; So, the code looks something like this…&lt;br /&gt;
&lt;div class=&quot;wlWriterEditableSmartContent&quot; id=&quot;scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:f18ce209-3851-4a7b-af45-74254c8a01ec&quot; style=&quot;display: inline; float: none; margin: 0px; padding: 0px;&quot;&gt;
&lt;div style=&quot;border: 1px solid rgb(0, 0, 128); color: black; font-family: &amp;quot;Courier New&amp;quot;, Courier, Monospace; font-size: 10pt;&quot;&gt;
&lt;div style=&quot;background: rgb(0, 0, 128); color: white; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px;&quot;&gt;
Code Snippet&lt;/div&gt;
&lt;div style=&quot;background: rgb(221, 221, 221); max-height: 300px; overflow: auto;&quot;&gt;
&lt;ol style=&quot;background: rgb(255, 255, 255); margin: 0px 0px 0px 2.5em; padding: 0px 0px 0px 5px; white-space: nowrap;&quot;&gt;
&lt;li&gt;&lt;span style=&quot;color: blue;&quot;&gt;using&lt;/span&gt; System;&lt;/li&gt;
&lt;li style=&quot;background: rgb(243, 243, 243);&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;using&lt;/span&gt; System.Collections.Generic;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;color: blue;&quot;&gt;using&lt;/span&gt; System.Linq;&lt;/li&gt;
&lt;li style=&quot;background: rgb(243, 243, 243);&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;using&lt;/span&gt; System.Text;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;color: blue;&quot;&gt;using&lt;/span&gt; System.ServiceModel;&lt;/li&gt;
&lt;li style=&quot;background: rgb(243, 243, 243);&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;using&lt;/span&gt; ExpressRecipeWCFLibrary;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&lt;/li&gt;
&lt;li style=&quot;background: rgb(243, 243, 243);&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;namespace&lt;/span&gt; ExpressRecipeWCFServices&lt;/li&gt;
&lt;li&gt;{&lt;/li&gt;
&lt;li style=&quot;background: rgb(243, 243, 243);&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;Program&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/li&gt;
&lt;li style=&quot;background: rgb(243, 243, 243);&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; Main(&lt;span style=&quot;color: blue;&quot;&gt;string&lt;/span&gt;[] args)&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/li&gt;
&lt;li style=&quot;background: rgb(243, 243, 243);&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #2b91af;&quot;&gt;ServiceHost&lt;/span&gt; host=&lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;ServiceHost&lt;/span&gt;(&lt;span style=&quot;color: blue;&quot;&gt;typeof&lt;/span&gt;(&lt;span style=&quot;color: #2b91af;&quot;&gt;UserService&lt;/span&gt;));&lt;/li&gt;
&lt;li&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;host.Closed += &lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;EventHandler&lt;/span&gt;(host_Closed);&lt;/li&gt;
&lt;li style=&quot;background: rgb(243, 243, 243);&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;host.Closing += &lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;EventHandler&lt;/span&gt;(host_Closing);&lt;/li&gt;
&lt;li&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;host.Faulted += &lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;EventHandler&lt;/span&gt;(host_Faulted);&lt;/li&gt;
&lt;li style=&quot;background: rgb(243, 243, 243);&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;host.Opened += &lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;EventHandler&lt;/span&gt;(host_Opened);&lt;/li&gt;
&lt;li&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;host.Opening += &lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;EventHandler&lt;/span&gt;(host_Opening);&lt;/li&gt;
&lt;li style=&quot;background: rgb(243, 243, 243);&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;host.UnknownMessageReceived += &lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;EventHandler&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #2b91af;&quot;&gt;UnknownMessageReceivedEventArgs&lt;/span&gt;&amp;gt;(host_UnknownMessageReceived);&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&lt;/li&gt;
&lt;li style=&quot;background: rgb(243, 243, 243);&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;host.Open();&lt;/li&gt;
&lt;li&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;System.&lt;span style=&quot;color: #2b91af;&quot;&gt;Console&lt;/span&gt;.WriteLine(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;User service started&quot;&lt;/span&gt;);&lt;/li&gt;
&lt;li style=&quot;background: rgb(243, 243, 243);&quot;&gt;&amp;nbsp;&lt;/li&gt;
&lt;li&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;System.&lt;span style=&quot;color: #2b91af;&quot;&gt;Console&lt;/span&gt;.WriteLine(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;Press &amp;lt;enter&amp;gt; to close&quot;&lt;/span&gt;);&lt;/li&gt;
&lt;li style=&quot;background: rgb(243, 243, 243);&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;System.&lt;span style=&quot;color: #2b91af;&quot;&gt;Console&lt;/span&gt;.ReadLine();&lt;/li&gt;
&lt;li&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;host.Close();&lt;/li&gt;
&lt;li style=&quot;background: rgb(243, 243, 243);&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&lt;/li&gt;
&lt;li style=&quot;background: rgb(243, 243, 243);&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; host_UnknownMessageReceived(&lt;span style=&quot;color: blue;&quot;&gt;object&lt;/span&gt; sender, &lt;span style=&quot;color: #2b91af;&quot;&gt;UnknownMessageReceivedEventArgs&lt;/span&gt; e)&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/li&gt;
&lt;li style=&quot;background: rgb(243, 243, 243);&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;System.&lt;span style=&quot;color: #2b91af;&quot;&gt;Console&lt;/span&gt;.WriteLine(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;Host unknown message&quot;&lt;/span&gt;);&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/li&gt;
&lt;li style=&quot;background: rgb(243, 243, 243);&quot;&gt;&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; host_Opening(&lt;span style=&quot;color: blue;&quot;&gt;object&lt;/span&gt; sender, &lt;span style=&quot;color: #2b91af;&quot;&gt;EventArgs&lt;/span&gt; e)&lt;/li&gt;
&lt;li style=&quot;background: rgb(243, 243, 243);&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/li&gt;
&lt;li&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;System.&lt;span style=&quot;color: #2b91af;&quot;&gt;Console&lt;/span&gt;.WriteLine(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;Host opening&quot;&lt;/span&gt;);&lt;/li&gt;
&lt;li style=&quot;background: rgb(243, 243, 243);&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&lt;/li&gt;
&lt;li style=&quot;background: rgb(243, 243, 243);&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; host_Opened(&lt;span style=&quot;color: blue;&quot;&gt;object&lt;/span&gt; sender, &lt;span style=&quot;color: #2b91af;&quot;&gt;EventArgs&lt;/span&gt; e)&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/li&gt;
&lt;li style=&quot;background: rgb(243, 243, 243);&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;System.&lt;span style=&quot;color: #2b91af;&quot;&gt;Console&lt;/span&gt;.WriteLine(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;Host opened&quot;&lt;/span&gt;);&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/li&gt;
&lt;li style=&quot;background: rgb(243, 243, 243);&quot;&gt;&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; host_Faulted(&lt;span style=&quot;color: blue;&quot;&gt;object&lt;/span&gt; sender, &lt;span style=&quot;color: #2b91af;&quot;&gt;EventArgs&lt;/span&gt; e)&lt;/li&gt;
&lt;li style=&quot;background: rgb(243, 243, 243);&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/li&gt;
&lt;li&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;System.&lt;span style=&quot;color: #2b91af;&quot;&gt;Console&lt;/span&gt;.WriteLine(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;Host faulted&quot;&lt;/span&gt;);&lt;/li&gt;
&lt;li style=&quot;background: rgb(243, 243, 243);&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&lt;/li&gt;
&lt;li style=&quot;background: rgb(243, 243, 243);&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; host_Closing(&lt;span style=&quot;color: blue;&quot;&gt;object&lt;/span&gt; sender, &lt;span style=&quot;color: #2b91af;&quot;&gt;EventArgs&lt;/span&gt; e)&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/li&gt;
&lt;li style=&quot;background: rgb(243, 243, 243);&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;System.&lt;span style=&quot;color: #2b91af;&quot;&gt;Console&lt;/span&gt;.WriteLine(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;Host closing&quot;&lt;/span&gt;);&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/li&gt;
&lt;li style=&quot;background: rgb(243, 243, 243);&quot;&gt;&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; host_Closed(&lt;span style=&quot;color: blue;&quot;&gt;object&lt;/span&gt; sender, &lt;span style=&quot;color: #2b91af;&quot;&gt;EventArgs&lt;/span&gt; e)&lt;/li&gt;
&lt;li style=&quot;background: rgb(243, 243, 243);&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/li&gt;
&lt;li&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;System.&lt;span style=&quot;color: #2b91af;&quot;&gt;Console&lt;/span&gt;.WriteLine(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;Host closed&quot;&lt;/span&gt;);&lt;/li&gt;
&lt;li style=&quot;background: rgb(243, 243, 243);&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/li&gt;
&lt;li style=&quot;background: rgb(243, 243, 243);&quot;&gt;}&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
Don’t worry, really not much code – most of it is writing to the console, mainly for the event handlers.&amp;nbsp; Ok, pretty normal code…guess we have the host so let’s run it.&lt;br /&gt;
Um…whoops – exception.&amp;nbsp; It runs the “host opening” event, then complains with:&lt;br /&gt;
&lt;blockquote&gt;
&lt;em&gt;“An unhandled exception of type &#39;System.InvalidOperationException&#39; occurred in System.ServiceModel.dll&lt;/em&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;em&gt;Additional information: Service &#39;ExpressRecipeWCFLibrary.UserService&#39; has zero application (non-infrastructure) endpoints. This might be because no configuration file was found for your application, or because no service element matching the service name could be found in the configuration file, or because no endpoints were defined in the service element.”&lt;/em&gt;&lt;/blockquote&gt;
Man, you mean VS 2010 doesn’t create a default endpoint?&amp;nbsp; And not even an App.Config file.&amp;nbsp; Oh well.&amp;nbsp; Yep, must add an App.Config file.&amp;nbsp; [this can be found in add new item under the project menu – application configuration file].&amp;nbsp; For simplicity sake, I left the name as the default…&lt;br /&gt;
Ok, so, now to reference the book, what needs to be in this config file?&amp;nbsp; Well, need an endpoint for the service, that part is obvious from the exception.&amp;nbsp; Need to add the service to the confile file as well…so something like:&lt;br /&gt;
&lt;div class=&quot;wlWriterEditableSmartContent&quot; id=&quot;scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:a751b4e6-81b1-4bf8-92dd-1f57478c08c2&quot; style=&quot;display: inline; float: none; margin: 0px; padding: 0px;&quot;&gt;
&lt;div style=&quot;border: 1px solid rgb(0, 0, 128); color: black; font-family: &amp;quot;Courier New&amp;quot;, Courier, Monospace; font-size: 10pt;&quot;&gt;
&lt;div style=&quot;background: rgb(0, 0, 128); color: white; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px;&quot;&gt;
Code Snippet&lt;/div&gt;
&lt;div style=&quot;background: rgb(221, 221, 221); max-height: 300px; overflow: auto;&quot;&gt;
&lt;ol style=&quot;background: rgb(255, 255, 255); margin: 0px 0px 0px 2.5em; padding: 0px 0px 0px 5px; white-space: nowrap;&quot;&gt;
&lt;li&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;?&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;xml&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;version&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&lt;/span&gt;&quot;&lt;span style=&quot;color: blue;&quot;&gt;1.0&lt;/span&gt;&quot;&lt;span style=&quot;color: blue;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;encoding&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&lt;/span&gt;&quot;&lt;span style=&quot;color: blue;&quot;&gt;utf-8&lt;/span&gt;&quot;&lt;span style=&quot;color: blue;&quot;&gt; ?&amp;gt;&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;background: rgb(243, 243, 243);&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;configuration&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;system.serviceModel&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;background: rgb(243, 243, 243);&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;services&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;service&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&lt;/span&gt;&quot;&lt;span style=&quot;color: blue;&quot;&gt;ExpressRecipeWCFLibrary.UserService&lt;/span&gt;&quot;&lt;span style=&quot;color: blue;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;background: rgb(243, 243, 243);&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;endpoint&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;address&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&lt;/span&gt;&quot;&lt;span style=&quot;color: blue;&quot;&gt;http://localhost:8000/UserService/&lt;/span&gt;&quot;&lt;span style=&quot;color: blue;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;binding&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&lt;/span&gt;&quot;&lt;span style=&quot;color: blue;&quot;&gt;wsHttpBinding&lt;/span&gt;&quot;&lt;span style=&quot;color: blue;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;contract&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&lt;/span&gt;&quot;&lt;span style=&quot;color: blue;&quot;&gt;ExpressRecipeWCFLibrary.IExpressRecipeUserContract&lt;/span&gt;&quot;&lt;span style=&quot;color: blue;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;service&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;background: rgb(243, 243, 243);&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;services&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;system.serviceModel&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;background: rgb(243, 243, 243);&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;configuration&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
Ok, not obvious but it works…have to add the service class to the services list with full namespace (required to be full? – don’t know).&amp;nbsp; Then to specify the endpoint - an endpoint is the combination of address, binding, and contract so all of that is specified.&amp;nbsp; I wanted http and decided to use the web service binding (instead of basic binding, which would be the default for an HTTP address) so that I could access this service via non-WCF clients [i.e. Java].&amp;nbsp; The contract is the interface for the service with namespace specified (again – required – not sure).&lt;br /&gt;
So, does it work this time?&amp;nbsp; Well, let’s see – Ctrl-F5.&amp;nbsp; &lt;br /&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWqdmEA-GtO5OY-bWhAn2k6hvCE3bR6bi1Fre8uqyM-v1ogYfltrrDcVtzTp__c8FKjgZxPsAstiPtoe8lCnoVvDLO4gepy1QxqP7aqNv7Cszt7aZ2EbWz1fEnldvzHTngJ7s25tj3nH4/s1600-h/image%25255B11%25255D.png&quot;&gt;&lt;img alt=&quot;image&quot; border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgxOdaTkQcfkriM28w07Ye_IjOW2GjdKyZZauAzMXVcUXMQcNTluRg3Ii6XYpo0yadFlKo4z9eY8gFHrYSXp9a4rKUWlG36i89jGPgzFFNklRF3RAK0zTIyr0hxNM4KzWutUe09KGahLJA/?imgmax=800&quot; height=&quot;167&quot; style=&quot;background-image: none; border-width: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; title=&quot;image&quot; width=&quot;463&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
Hmm, yep…ok, let’s try to get to the WSDL of the service.&amp;nbsp; In the browser: http://localhost:8000/UserService/ – um, nope – “The webpage cannot be found.”&amp;nbsp; Ok, well, let’s try http://localhost:8000/ – nope – still “The webpage cannot be found.” &lt;br /&gt;
Now what…well, according to the book, page 39, Metadata Exchange – “by default, the service will not publish its metadata.”&amp;nbsp; Well, further reading (after the very discouraging “publishing your service’s metadata involves significant effort”) we find that we can do this in a couple ways.&amp;nbsp; I chose one that seemed the easiest to me – enabling the metadata behavior (httpGetEnabled) on the endpoint.&lt;br /&gt;
So, going off the example in the book, my App.Config now looks like:&lt;br /&gt;
&lt;div class=&quot;wlWriterEditableSmartContent&quot; id=&quot;scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:2694c1c0-5746-4442-ac7d-273c46fcdf5b&quot; style=&quot;display: inline; float: none; margin: 0px; padding: 0px;&quot;&gt;
&lt;div style=&quot;border: 1px solid rgb(0, 0, 128); color: black; font-family: &amp;quot;Courier New&amp;quot;, Courier, Monospace; font-size: 10pt;&quot;&gt;
&lt;div style=&quot;background: rgb(0, 0, 128); color: white; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px;&quot;&gt;
Code Snippet&lt;/div&gt;
&lt;div style=&quot;background: rgb(221, 221, 221); max-height: 300px; overflow: auto;&quot;&gt;
&lt;ol style=&quot;background: rgb(255, 255, 255); margin: 0px 0px 0px 2.5em; padding: 0px 0px 0px 5px; white-space: nowrap;&quot;&gt;
&lt;li&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;?&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;xml&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;version&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&lt;/span&gt;&quot;&lt;span style=&quot;color: blue;&quot;&gt;1.0&lt;/span&gt;&quot;&lt;span style=&quot;color: blue;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;encoding&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&lt;/span&gt;&quot;&lt;span style=&quot;color: blue;&quot;&gt;utf-8&lt;/span&gt;&quot;&lt;span style=&quot;color: blue;&quot;&gt; ?&amp;gt;&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;background: rgb(243, 243, 243);&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;configuration&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;system.serviceModel&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;background: rgb(243, 243, 243);&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;services&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;service&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&lt;/span&gt;&quot;&lt;span style=&quot;color: blue;&quot;&gt;ExpressRecipeWCFLibrary.UserService&lt;/span&gt;&quot;&lt;span style=&quot;color: blue;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;behaviorConfiguration&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&lt;/span&gt;&quot;&lt;span style=&quot;color: blue;&quot;&gt;MEXGET&lt;/span&gt;&quot;&lt;span style=&quot;color: blue;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;background: rgb(243, 243, 243);&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;endpoint&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;address&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&lt;/span&gt;&quot;&lt;span style=&quot;color: blue;&quot;&gt;http://localhost:8000/UserService/&lt;/span&gt;&quot;&lt;span style=&quot;color: blue;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;binding&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&lt;/span&gt;&quot;&lt;span style=&quot;color: blue;&quot;&gt;wsHttpBinding&lt;/span&gt;&quot;&lt;span style=&quot;color: blue;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;contract&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&lt;/span&gt;&quot;&lt;span style=&quot;color: blue;&quot;&gt;ExpressRecipeWCFLibrary.IExpressRecipeUserContract&lt;/span&gt;&quot;&lt;span style=&quot;color: blue;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;service&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;background: rgb(243, 243, 243);&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;services&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;behaviors&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;background: rgb(243, 243, 243);&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;serviceBehaviors&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;behavior&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&lt;/span&gt;&quot;&lt;span style=&quot;color: blue;&quot;&gt;MEXGET&lt;/span&gt;&quot;&lt;span style=&quot;color: blue;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;background: rgb(243, 243, 243);&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;serviceMetadata&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;httpGetEnabled&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&lt;/span&gt;&quot;&lt;span style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;&quot;&lt;span style=&quot;color: blue;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;behavior&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;background: rgb(243, 243, 243);&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;serviceBehaviors&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;behaviors&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;background: rgb(243, 243, 243);&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;system.serviceModel&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;configuration&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
Does it run?&amp;nbsp; Nope.&amp;nbsp; It actually stopped after the host faulted event was called and gave this exception:&lt;br /&gt;
&lt;blockquote&gt;
&lt;em&gt;“The HttpGetEnabled property of ServiceMetadataBehavior is set to true and the HttpGetUrl property is a relative address, but there is no http base address.&amp;nbsp; Either supply an http base address or set HttpGetUrl to an absolute address.”&lt;/em&gt;&lt;/blockquote&gt;
Ok, so now what?&amp;nbsp; Looking at the book’s example a bit more closely it shows the base address off of the host element of the service…and no endpoint element.&amp;nbsp; Ok, so, I replaced it with:&lt;br /&gt;
&lt;div class=&quot;wlWriterEditableSmartContent&quot; id=&quot;scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:93fbbc21-4b5b-4cde-aee1-9c4990e98dd1&quot; style=&quot;display: inline; float: none; margin: 0px; padding: 0px;&quot;&gt;
&lt;div style=&quot;border: 1px solid rgb(0, 0, 128); color: black; font-family: &amp;quot;Courier New&amp;quot;, Courier, Monospace; font-size: 10pt;&quot;&gt;
&lt;div style=&quot;background: rgb(0, 0, 128); color: white; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px;&quot;&gt;
Code Snippet&lt;/div&gt;
&lt;div style=&quot;background: rgb(221, 221, 221); max-height: 300px; overflow: auto;&quot;&gt;
&lt;ol style=&quot;background: rgb(255, 255, 255); margin: 0px 0px 0px 2.5em; padding: 0px 0px 0px 5px; white-space: nowrap;&quot;&gt;
&lt;li&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;?&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;xml&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;version&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&lt;/span&gt;&quot;&lt;span style=&quot;color: blue;&quot;&gt;1.0&lt;/span&gt;&quot;&lt;span style=&quot;color: blue;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;encoding&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&lt;/span&gt;&quot;&lt;span style=&quot;color: blue;&quot;&gt;utf-8&lt;/span&gt;&quot;&lt;span style=&quot;color: blue;&quot;&gt; ?&amp;gt;&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;background: rgb(243, 243, 243);&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;configuration&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;system.serviceModel&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;background: rgb(243, 243, 243);&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;services&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;service&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&lt;/span&gt;&quot;&lt;span style=&quot;color: blue;&quot;&gt;ExpressRecipeWCFLibrary.UserService&lt;/span&gt;&quot;&lt;span style=&quot;color: blue;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;behaviorConfiguration&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&lt;/span&gt;&quot;&lt;span style=&quot;color: blue;&quot;&gt;MEXGET&lt;/span&gt;&quot;&lt;span style=&quot;color: blue;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;background: rgb(243, 243, 243);&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;host&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;baseAddresses&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;background: rgb(243, 243, 243);&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;add&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;baseAddress&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&lt;/span&gt;&quot;&lt;span style=&quot;color: blue;&quot;&gt;http://localhost:8000/UserService/&lt;/span&gt;&quot;&lt;span style=&quot;color: blue;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;baseAddresses&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;background: rgb(243, 243, 243);&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;host&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;!--&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&amp;lt;endpoint address=&quot;UserService/&quot; binding=&quot;wsHttpBinding&quot; contract=&quot;ExpressRecipeWCFLibrary.IExpressRecipeUserContract&quot;/&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;--&amp;gt;&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;background: rgb(243, 243, 243);&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;service&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;services&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;background: rgb(243, 243, 243);&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;behaviors&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;serviceBehaviors&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;background: rgb(243, 243, 243);&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;behavior&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&lt;/span&gt;&quot;&lt;span style=&quot;color: blue;&quot;&gt;MEXGET&lt;/span&gt;&quot;&lt;span style=&quot;color: blue;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;serviceMetadata&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;httpGetEnabled&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&lt;/span&gt;&quot;&lt;span style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;&quot;&lt;span style=&quot;color: blue;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;background: rgb(243, 243, 243);&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;behavior&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;serviceBehaviors&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;background: rgb(243, 243, 243);&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;behaviors&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;system.serviceModel&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;background: rgb(243, 243, 243);&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;configuration&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
I list my binding by doing this, something I’ll get back at a later time…and the contract is now gone as well.&amp;nbsp; Well, will this even work?&lt;br /&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWqdmEA-GtO5OY-bWhAn2k6hvCE3bR6bi1Fre8uqyM-v1ogYfltrrDcVtzTp__c8FKjgZxPsAstiPtoe8lCnoVvDLO4gepy1QxqP7aqNv7Cszt7aZ2EbWz1fEnldvzHTngJ7s25tj3nH4/s1600-h/image%25255B11%25255D.png&quot;&gt;&lt;img alt=&quot;image&quot; border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgxOdaTkQcfkriM28w07Ye_IjOW2GjdKyZZauAzMXVcUXMQcNTluRg3Ii6XYpo0yadFlKo4z9eY8gFHrYSXp9a4rKUWlG36i89jGPgzFFNklRF3RAK0zTIyr0hxNM4KzWutUe09KGahLJA/?imgmax=800&quot; height=&quot;167&quot; style=&quot;background-image: none; border-width: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; title=&quot;image&quot; width=&quot;463&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
How’d that happen?&amp;nbsp; Ok, let’s see if we can access the WSDL in the browser by going to the base address specified (http://localhost:8000/UserService/).&lt;br /&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh-1NAL1D21h4WxEM3eLux5nGVTj_6Cz6P8YW5zvkFDDNwDaBDLr1MH_WFxgj5lMSZbtGUGIdKNNpyOFHHRfhwUPtmMLcDBMW1BC4ITrd7BbAX5OhagKx6dYBpuLzHGXfgp_ZcYvMLHwls/s1600-h/image%25255B19%25255D.png&quot;&gt;&lt;img alt=&quot;image&quot; border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhrrnOUJx0k3bmOi7rrtlgBC5BkqkAzrK9FUtWVGmtkHC3-_SW-CtaZciW63LiHD5rbufH0xDM8rliCMnJHF3HOEGRHadInIUluM2ipI2Z8f3dFJ9CtA6qNrqjd3dapthLUgo5W8Dl9Gus/?imgmax=800&quot; height=&quot;416&quot; style=&quot;background-image: none; border: 0px currentColor; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; title=&quot;image&quot; width=&quot;547&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
Oh, cool…appears to be working…will try to get the binding back at a later time and create a client to call the AddUser method.</content><link rel='replies' type='application/atom+xml' href='http://rhale78.blogspot.com/feeds/686783710732331297/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://rhale78.blogspot.com/2011/05/trial-and-errorwcf-services-part-1.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/270091469191232126/posts/default/686783710732331297'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/270091469191232126/posts/default/686783710732331297'/><link rel='alternate' type='text/html' href='http://rhale78.blogspot.com/2011/05/trial-and-errorwcf-services-part-1.html' title='Trial and Error–WCF Services Part 1'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/09185478558704427023</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgxOdaTkQcfkriM28w07Ye_IjOW2GjdKyZZauAzMXVcUXMQcNTluRg3Ii6XYpo0yadFlKo4z9eY8gFHrYSXp9a4rKUWlG36i89jGPgzFFNklRF3RAK0zTIyr0hxNM4KzWutUe09KGahLJA/s72-c?imgmax=800" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-270091469191232126.post-864874867486964422</id><published>2011-05-24T12:57:00.001-04:00</published><updated>2011-05-24T12:57:51.661-04:00</updated><category scheme="http://www.blogger.com/atom/ns#" term=".Net 4.0"/><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="dynamics"/><title type='text'>Dynamics in .Net 4.0</title><content type='html'>&lt;p&gt;One of the new features of .Net 4.0 is the concept of a dynamic type.&amp;nbsp; In general terms, it allows the programmer to perform “late binding” at run time.&amp;nbsp; So, what’s so special about that – the object type allows “late binding”.&amp;nbsp; Well, does it?&amp;nbsp; What if you don’t know what type the object is but you do know it will support a method or operation?&amp;nbsp; Yes, you can always use “typeof”, “is”, or “instanceof” operators to test that it is a specific type or inherits from a specific type – but what if the method or operator doesn’t have a common inheritance tree – such as most of the operators (+, –, etc) or what if there are many possibilities/combinations.&amp;nbsp; The dynamic type solves a lot of the type checking and casting that would be required in previous versions of .Net.&lt;/p&gt; &lt;p&gt;For example, let’s say you’re wanting to do addition on two objects.&amp;nbsp; Let’s assume that both these objects support +.&amp;nbsp; The general concept of late binding says that you “should” be able to do something like:&lt;/p&gt;&lt;pre style=&quot;border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 549px; padding-right: 5px; height: 63px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px&quot;&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;  1: &lt;span style=&quot;color: #0000ff&quot;&gt;object&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;value&lt;/span&gt;1=1;&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;  2: &lt;span style=&quot;color: #0000ff&quot;&gt;object&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;value&lt;/span&gt;2=2;&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;  3: &lt;span style=&quot;color: #0000ff&quot;&gt;object&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;value&lt;/span&gt;3=&lt;span style=&quot;color: #0000ff&quot;&gt;value&lt;/span&gt;1+&lt;span style=&quot;color: #0000ff&quot;&gt;value&lt;/span&gt;2;&lt;/pre&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;The above code will give you “Error 1 Operator &#39;+&#39; cannot be applied to operands of type &#39;object&#39; and &#39;object&#39;”.&amp;nbsp; The solution is to cast these as ints such as:&lt;/p&gt;&lt;pre style=&quot;border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 548px; padding-right: 5px; height: 63px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px&quot;&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;  1: &lt;span style=&quot;color: #0000ff&quot;&gt;object&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;value&lt;/span&gt;1 = 1;&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;  2: &lt;span style=&quot;color: #0000ff&quot;&gt;object&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;value&lt;/span&gt;2 = 2;&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;  3: &lt;span style=&quot;color: #0000ff&quot;&gt;object&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;value&lt;/span&gt;3 = (&lt;span style=&quot;color: #0000ff&quot;&gt;int&lt;/span&gt;)&lt;span style=&quot;color: #0000ff&quot;&gt;value&lt;/span&gt;1 + (&lt;span style=&quot;color: #0000ff&quot;&gt;int&lt;/span&gt;)&lt;span style=&quot;color: #0000ff&quot;&gt;value&lt;/span&gt;2;&lt;/pre&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;Ok, so that works – no compile error…but, what if value1 was a double, not an int…or, what if value1 or value2 could be either int or double…then you’re stuck with some nasty code like:&lt;/p&gt;&lt;pre style=&quot;border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 548px; padding-right: 5px; height: 454px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px&quot;&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;  1: &lt;span style=&quot;color: #0000ff&quot;&gt;object&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;value&lt;/span&gt;1 = 1;&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;  2: &lt;span style=&quot;color: #0000ff&quot;&gt;object&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;value&lt;/span&gt;2 = 2;&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;  3: &lt;span style=&quot;color: #0000ff&quot;&gt;object&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;value&lt;/span&gt;3;&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;  4: &lt;span style=&quot;color: #0000ff&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #0000ff&quot;&gt;value&lt;/span&gt;1 &lt;span style=&quot;color: #0000ff&quot;&gt;is&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;int&lt;/span&gt;)&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;  5: {&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;  6:     &lt;span style=&quot;color: #0000ff&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #0000ff&quot;&gt;value&lt;/span&gt;2 &lt;span style=&quot;color: #0000ff&quot;&gt;is&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;int&lt;/span&gt;)&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;  7:     {&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;  8:         &lt;span style=&quot;color: #0000ff&quot;&gt;value&lt;/span&gt;3 = (&lt;span style=&quot;color: #0000ff&quot;&gt;int&lt;/span&gt;)&lt;span style=&quot;color: #0000ff&quot;&gt;value&lt;/span&gt;1 + (&lt;span style=&quot;color: #0000ff&quot;&gt;int&lt;/span&gt;)&lt;span style=&quot;color: #0000ff&quot;&gt;value&lt;/span&gt;2;&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;  9:     }&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt; 10:     &lt;span style=&quot;color: #0000ff&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #0000ff&quot;&gt;value&lt;/span&gt;2 &lt;span style=&quot;color: #0000ff&quot;&gt;is&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;double&lt;/span&gt;)&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt; 11:     {&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt; 12:         &lt;span style=&quot;color: #0000ff&quot;&gt;value&lt;/span&gt;3 = (&lt;span style=&quot;color: #0000ff&quot;&gt;int&lt;/span&gt;)&lt;span style=&quot;color: #0000ff&quot;&gt;value&lt;/span&gt;1 + (&lt;span style=&quot;color: #0000ff&quot;&gt;double&lt;/span&gt;)&lt;span style=&quot;color: #0000ff&quot;&gt;value&lt;/span&gt;2;&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt; 13:     }&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt; 14: }&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt; 15: &lt;span style=&quot;color: #0000ff&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #0000ff&quot;&gt;value&lt;/span&gt;1 &lt;span style=&quot;color: #0000ff&quot;&gt;is&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;double&lt;/span&gt;)&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt; 16: {&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt; 17:     &lt;span style=&quot;color: #0000ff&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #0000ff&quot;&gt;value&lt;/span&gt;2 &lt;span style=&quot;color: #0000ff&quot;&gt;is&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;int&lt;/span&gt;)&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt; 18:     {&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt; 19:         &lt;span style=&quot;color: #0000ff&quot;&gt;value&lt;/span&gt;3 = (&lt;span style=&quot;color: #0000ff&quot;&gt;double&lt;/span&gt;)&lt;span style=&quot;color: #0000ff&quot;&gt;value&lt;/span&gt;1 + (&lt;span style=&quot;color: #0000ff&quot;&gt;int&lt;/span&gt;)&lt;span style=&quot;color: #0000ff&quot;&gt;value&lt;/span&gt;2;&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt; 20:     }&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt; 21:     &lt;span style=&quot;color: #0000ff&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #0000ff&quot;&gt;value&lt;/span&gt;2 &lt;span style=&quot;color: #0000ff&quot;&gt;is&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;double&lt;/span&gt;)&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt; 22:     {&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt; 23:         &lt;span style=&quot;color: #0000ff&quot;&gt;value&lt;/span&gt;3 = (&lt;span style=&quot;color: #0000ff&quot;&gt;double&lt;/span&gt;)&lt;span style=&quot;color: #0000ff&quot;&gt;value&lt;/span&gt;1 + (&lt;span style=&quot;color: #0000ff&quot;&gt;int&lt;/span&gt;)&lt;span style=&quot;color: #0000ff&quot;&gt;value&lt;/span&gt;2;&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt; 24:     }&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt; 25: }&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt; 26: &lt;/pre&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;Add another type that both could be and it increases the code more…not nice at all.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Around .Net 3.5, Microsoft added the var type.&amp;nbsp; The var type infers a type at design time.&amp;nbsp; This is nice in our example case and actually works so:&lt;/p&gt;&lt;pre style=&quot;border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 547px; padding-right: 5px; height: 63px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px&quot;&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;  1: var &lt;span style=&quot;color: #0000ff&quot;&gt;value&lt;/span&gt;1 = 1;&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;  2: var &lt;span style=&quot;color: #0000ff&quot;&gt;value&lt;/span&gt;2 = 2;&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;  3: var &lt;span style=&quot;color: #0000ff&quot;&gt;value&lt;/span&gt;3 = &lt;span style=&quot;color: #0000ff&quot;&gt;value&lt;/span&gt;1 + &lt;span style=&quot;color: #0000ff&quot;&gt;value&lt;/span&gt;2;&lt;/pre&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;Actually works – it compiles and we get 3.&amp;nbsp; If we change a or b to be a double, value3 gets a double result (double + int=double) as expected if we had explicitly typed the variables.&amp;nbsp; Great, problem solved – right?&amp;nbsp; Wrong…&amp;nbsp; Let’s add another monkey wrench into this…&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Suppose we want a function that converts a string to the “best” type that that string represents.&amp;nbsp; So, a string value of “2.4” would return a double 2.4, a “12/25/2011” would return a DateTime of 12/25/2011, etc.&amp;nbsp; Then we’d like to take the result of that and add it to another result from that same function.&amp;nbsp; This would work with object, but we’d be back in the exact same situation as before – testing with “is” and casting.&amp;nbsp; What about var?&amp;nbsp; (the GetBestType function is a prototype only – it works but it needs more error checking, validation, etc).&lt;/p&gt;&lt;pre style=&quot;border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 548px; padding-right: 5px; height: 471px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px&quot;&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;  1: var &lt;span style=&quot;color: #0000ff&quot;&gt;value&lt;/span&gt;1 = GetBestType(&quot;&lt;span style=&quot;color: #8b0000&quot;&gt;1.2&lt;/span&gt;&quot;);&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;  2: var &lt;span style=&quot;color: #0000ff&quot;&gt;value&lt;/span&gt;2 = GetBestType(&quot;&lt;span style=&quot;color: #8b0000&quot;&gt;2&lt;/span&gt;&quot;);&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;  3: var &lt;span style=&quot;color: #0000ff&quot;&gt;value&lt;/span&gt;3 = &lt;span style=&quot;color: #0000ff&quot;&gt;value&lt;/span&gt;1 + &lt;span style=&quot;color: #0000ff&quot;&gt;value&lt;/span&gt;2;&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;  4: &lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;  5: &lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; var GetBestType(&lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;value&lt;/span&gt;)&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;  6: {&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;  7:     &lt;span style=&quot;color: #0000ff&quot;&gt;double&lt;/span&gt; doubleResult;&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;  8:     &lt;span style=&quot;color: #0000ff&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #0000ff&quot;&gt;double&lt;/span&gt;.TryParse(&lt;span style=&quot;color: #0000ff&quot;&gt;value&lt;/span&gt;, &lt;span style=&quot;color: #0000ff&quot;&gt;out&lt;/span&gt; doubleResult))&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;  9:     {&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt; 10:         &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; doubleResult;&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt; 11:     }&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt; 12: &lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt; 13:     &lt;span style=&quot;color: #0000ff&quot;&gt;int&lt;/span&gt; intResult;&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt; 14:     &lt;span style=&quot;color: #0000ff&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #0000ff&quot;&gt;int&lt;/span&gt;.TryParse(&lt;span style=&quot;color: #0000ff&quot;&gt;value&lt;/span&gt;, &lt;span style=&quot;color: #0000ff&quot;&gt;out&lt;/span&gt; intResult))&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt; 15:     {&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt; 16:         &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; intResult;&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt; 17:     }&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt; 18:     &lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt; 19:     DateTime dateResult;&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt; 20:     &lt;span style=&quot;color: #0000ff&quot;&gt;if&lt;/span&gt; (DateTime.TryParse(&lt;span style=&quot;color: #0000ff&quot;&gt;value&lt;/span&gt;, &lt;span style=&quot;color: #0000ff&quot;&gt;out&lt;/span&gt; dateResult))&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt; 21:     {&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt; 22:         &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; dateResult;&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt; 23:     }&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt; 24: &lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt; 25:     &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;value&lt;/span&gt;;&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt; 26: }&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt; 27: &lt;/pre&gt;&lt;/pre&gt;Well, first thing with that code – won’t even compile.&amp;nbsp; Seems the var keyword is only for local variables.&amp;nbsp; Well, back to old reliable object, right?&amp;nbsp; If we were using .Net 3.5 or before, yes…this is where dynamic comes in for .Net 4.0. &lt;br /&gt;&lt;p&gt;The dynamic type is determined at run time…so, fixing our code to use dynamic, we can do this:&lt;/p&gt;&lt;pre style=&quot;border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 547px; padding-right: 5px; height: 454px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px&quot;&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;  1: var &lt;span style=&quot;color: #0000ff&quot;&gt;value&lt;/span&gt;1 = GetBestType(&quot;&lt;span style=&quot;color: #8b0000&quot;&gt;1.2&lt;/span&gt;&quot;);&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;  2: var &lt;span style=&quot;color: #0000ff&quot;&gt;value&lt;/span&gt;2 = GetBestType(&quot;&lt;span style=&quot;color: #8b0000&quot;&gt;2&lt;/span&gt;&quot;);&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;  3: var &lt;span style=&quot;color: #0000ff&quot;&gt;value&lt;/span&gt;3 = &lt;span style=&quot;color: #0000ff&quot;&gt;value&lt;/span&gt;1 + &lt;span style=&quot;color: #0000ff&quot;&gt;value&lt;/span&gt;2;&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;  4: &lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;  5: &lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; dynamic GetBestType(&lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;value&lt;/span&gt;)&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;  6: {&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;  7:     &lt;span style=&quot;color: #0000ff&quot;&gt;double&lt;/span&gt; doubleResult;&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;  8:     &lt;span style=&quot;color: #0000ff&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #0000ff&quot;&gt;double&lt;/span&gt;.TryParse(&lt;span style=&quot;color: #0000ff&quot;&gt;value&lt;/span&gt;, &lt;span style=&quot;color: #0000ff&quot;&gt;out&lt;/span&gt; doubleResult))&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;  9:     {&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt; 10:         &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; doubleResult;&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt; 11:     }&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt; 12: &lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt; 13:     &lt;span style=&quot;color: #0000ff&quot;&gt;int&lt;/span&gt; intResult;&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt; 14:     &lt;span style=&quot;color: #0000ff&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #0000ff&quot;&gt;int&lt;/span&gt;.TryParse(&lt;span style=&quot;color: #0000ff&quot;&gt;value&lt;/span&gt;, &lt;span style=&quot;color: #0000ff&quot;&gt;out&lt;/span&gt; intResult))&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt; 15:     {&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt; 16:         &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; intResult;&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt; 17:     }&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt; 18:     &lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt; 19:     DateTime dateResult;&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt; 20:     &lt;span style=&quot;color: #0000ff&quot;&gt;if&lt;/span&gt; (DateTime.TryParse(&lt;span style=&quot;color: #0000ff&quot;&gt;value&lt;/span&gt;, &lt;span style=&quot;color: #0000ff&quot;&gt;out&lt;/span&gt; dateResult))&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt; 21:     {&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt; 22:         &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; dateResult;&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt; 23:     }&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt; 24: &lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt; 25:     &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;value&lt;/span&gt;;&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt; 26: }&lt;/pre&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;Yes, we’re returning either a double, an int, a DateTime, or a string from one function and the code works as expected.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;While the above code works, and minimizes code vs late binding type checking, both the dynamic and var keywords should be used sparingly in favor of code readability.&amp;nbsp; Technically, while you could create every variable as var or dynamic, it would greatly reduce readability…so, use sparingly when needed (i.e. when you’d be tempted to use object and type checking).&amp;nbsp; It is much better than using object, but it should never replace a explicitly typed variable, if you have the choice.&lt;/p&gt;  </content><link rel='replies' type='application/atom+xml' href='http://rhale78.blogspot.com/feeds/864874867486964422/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://rhale78.blogspot.com/2011/05/dynamics-in-net-40.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/270091469191232126/posts/default/864874867486964422'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/270091469191232126/posts/default/864874867486964422'/><link rel='alternate' type='text/html' href='http://rhale78.blogspot.com/2011/05/dynamics-in-net-40.html' title='Dynamics in .Net 4.0'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/09185478558704427023</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-270091469191232126.post-557822608685160715</id><published>2011-05-24T10:59:00.001-04:00</published><updated>2011-05-24T11:00:40.881-04:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="Design Pattern"/><title type='text'>Static Constructors in .Net</title><content type='html'>&lt;p&gt;Suppose you’re creating a class in .Net and you want certain operations only done once, at the very first time your class is used.&amp;nbsp; First thoughts?&amp;nbsp; A flag to test to see if it’s the first time into the class – suppose your class has 100 static and non-static functions – that code to do the check must be in each of those.&amp;nbsp; What a pain…&amp;nbsp; Next idea? (And, no, you’re not allowed to cheat and use a Singleton)&amp;nbsp; What?&amp;nbsp; No more ideas…&lt;/p&gt; &lt;p&gt;The solution – use a static constructor.&amp;nbsp; Static constructors are called only once, when the class is first used, either through static members or object members (i.e. non-statics).&lt;/p&gt; &lt;p&gt;Static constructors are really not much different from regular constructors in definition except they can’t have access modifiers (i.e. public, private, protected, etc).&amp;nbsp; They are called before the normal constructor.&amp;nbsp; But, being static, they can only access static members of that class.&amp;nbsp; Here’re the other rules about static constructors from Microsoft (&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/k9x6w0hc(v=VS.100).aspx&quot;&gt;http://msdn.microsoft.com/en-us/library/k9x6w0hc(v=VS.100).aspx&lt;/a&gt;):&lt;/p&gt; &lt;ul&gt; &lt;li&gt; &lt;p&gt;A static constructor does not take access modifiers or have parameters.&lt;/p&gt; &lt;li&gt; &lt;p&gt;A static constructor is called automatically to initialize the &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/0b0thckt.aspx&quot;&gt;&lt;font color=&quot;#1364c4&quot;&gt;class&lt;/font&gt;&lt;/a&gt; before the first instance is created or any static members are referenced. &lt;/p&gt; &lt;li&gt; &lt;p&gt;A static constructor cannot be called directly.&lt;/p&gt; &lt;li&gt; &lt;p&gt;The user has no control on when the static constructor is executed in the program.&lt;/p&gt; &lt;li&gt; &lt;p&gt;A typical use of static constructors is when the class is using a log file and the constructor is used to write entries to this file.&lt;/p&gt; &lt;li&gt; &lt;p&gt;Static constructors are also useful when creating wrapper classes for unmanaged code, when the constructor can call the &lt;span&gt;&lt;span class=&quot;input&quot;&gt;LoadLibrary&lt;/span&gt;&lt;/span&gt; method.&lt;/p&gt; &lt;li&gt; &lt;p&gt;If a static constructor throws an exception, the runtime will not invoke it a second time, and the type will remain uninitialized for the lifetime of the application domain in which your program is running.&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;Here’s a quick example class that creates a Singleton using the static constructor.&lt;/p&gt;&lt;pre style=&quot;border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 548px; padding-right: 5px; height: 318px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px&quot;&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;  1: &lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;class&lt;/span&gt; StaticSingleton&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;  2:     {&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;  3:         &lt;span style=&quot;color: #0000ff&quot;&gt;static&lt;/span&gt; StaticSingleton staticSingleton;&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;  4: &lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;  5:         &lt;span style=&quot;color: #0000ff&quot;&gt;private&lt;/span&gt; StaticSingleton ()&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;  6:         {&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;  7:         }&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;  8: &lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;  9:         &lt;span style=&quot;color: #0000ff&quot;&gt;static&lt;/span&gt; StaticSingleton()&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt; 10:         {&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt; 11:             staticSingleton = &lt;span style=&quot;color: #0000ff&quot;&gt;new&lt;/span&gt; StaticSingleton();&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt; 12:         }&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt; 13: &lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt; 14:         &lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;static&lt;/span&gt; StaticSingleton GetInstance()&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt; 15:         {&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt; 16:             &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; staticSingleton;&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt; 17:         }&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt; 18:     }&lt;/pre&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;Here’s the non-static constructor version for comparison:&lt;/p&gt;&lt;pre style=&quot;border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 547px; padding-right: 5px; height: 301px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px&quot;&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;  1:     &lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;class&lt;/span&gt; Singleton&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;  2:     {&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;  3:         &lt;span style=&quot;color: #0000ff&quot;&gt;static&lt;/span&gt; Singleton singleton;&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;  4: &lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;  5:         &lt;span style=&quot;color: #0000ff&quot;&gt;private&lt;/span&gt; Singleton()&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;  6:         {&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;  7:         }&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;  8: &lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;  9:         &lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;static&lt;/span&gt; Singleton GetInstance()&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt; 10:         {&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt; 11:             &lt;span style=&quot;color: #0000ff&quot;&gt;if&lt;/span&gt; (singleton == &lt;span style=&quot;color: #0000ff&quot;&gt;null&lt;/span&gt;)&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt; 12:             {&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt; 13:                 singleton = &lt;span style=&quot;color: #0000ff&quot;&gt;new&lt;/span&gt; Singleton();&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt; 14:             }&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt; 15:             &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; singleton;&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt; 16:         }&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt; 17:     }&lt;/pre&gt;&lt;/pre&gt;  </content><link rel='replies' type='application/atom+xml' href='http://rhale78.blogspot.com/feeds/557822608685160715/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://rhale78.blogspot.com/2011/05/static-constructors-in-net.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/270091469191232126/posts/default/557822608685160715'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/270091469191232126/posts/default/557822608685160715'/><link rel='alternate' type='text/html' href='http://rhale78.blogspot.com/2011/05/static-constructors-in-net.html' title='Static Constructors in .Net'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/09185478558704427023</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-270091469191232126.post-1522731978569880539</id><published>2011-05-20T15:54:00.001-04:00</published><updated>2011-05-20T15:54:27.536-04:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL"/><title type='text'>True Random Numbers in SQL</title><content type='html'>&lt;p&gt;Co-worker stumbled across this one and thought it was a good way to generate random numbers in SQL Server.&lt;/p&gt; &lt;p&gt;Often, random numbers are driven off of the uniqueness of the ticks/millisecond part of the current date/time but that code may run so quickly that you’re not guaranteed a different value between each random request.&amp;nbsp; &lt;/p&gt; &lt;p&gt;The solution – use GUIDs as the source for the random function as GUIDs are “guaranteed” to be unique.&amp;nbsp; Of course, some casting is involved as the random function does not take a string.&amp;nbsp; So, the solution is to cast the GUID as a var binary, then convert that to an int, then pass the absolute value of that that into rand (since it only allows positive ints).&amp;nbsp; Here’s the general code:&lt;/p&gt;&lt;pre style=&quot;border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 544px; padding-right: 5px; height: 52px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px&quot;&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;  1: RAND(ABS(&lt;a style=&quot;color: #0000ff&quot; href=&quot;http://search.microsoft.com/default.asp?so=RECCNT&amp;amp;siteid=us%2Fdev&amp;amp;p=1&amp;amp;nq=NEW&amp;amp;qu=CAST&amp;amp;IntlSearch=&amp;amp;boolean=PHRASE&amp;amp;ig=01&amp;amp;i=09&amp;amp;i=99&quot;&gt;CAST&lt;/a&gt;(&lt;a style=&quot;color: #0000ff&quot; href=&quot;http://search.microsoft.com/default.asp?so=RECCNT&amp;amp;siteid=us%2Fdev&amp;amp;p=1&amp;amp;nq=NEW&amp;amp;qu=CAST&amp;amp;IntlSearch=&amp;amp;boolean=PHRASE&amp;amp;ig=01&amp;amp;i=09&amp;amp;i=99&quot;&gt;CAST&lt;/a&gt;(NEWID() &lt;a style=&quot;color: #0000ff&quot; href=&quot;http://search.microsoft.com/default.asp?so=RECCNT&amp;amp;siteid=us%2Fdev&amp;amp;p=1&amp;amp;nq=NEW&amp;amp;qu=AS&amp;amp;IntlSearch=&amp;amp;boolean=PHRASE&amp;amp;ig=01&amp;amp;i=09&amp;amp;i=99&quot;&gt;AS&lt;/a&gt; &lt;a style=&quot;color: #0000ff&quot; href=&quot;http://search.microsoft.com/default.asp?so=RECCNT&amp;amp;siteid=us%2Fdev&amp;amp;p=1&amp;amp;nq=NEW&amp;amp;qu=VARBINARY&amp;amp;IntlSearch=&amp;amp;boolean=PHRASE&amp;amp;ig=01&amp;amp;i=09&amp;amp;i=99&quot;&gt;VARBINARY&lt;/a&gt;) &lt;a style=&quot;color: #0000ff&quot; href=&quot;http://search.microsoft.com/default.asp?so=RECCNT&amp;amp;siteid=us%2Fdev&amp;amp;p=1&amp;amp;nq=NEW&amp;amp;qu=AS&amp;amp;IntlSearch=&amp;amp;boolean=PHRASE&amp;amp;ig=01&amp;amp;i=09&amp;amp;i=99&quot;&gt;AS&lt;/a&gt; &lt;a style=&quot;color: #0000ff&quot; href=&quot;http://search.microsoft.com/default.asp?so=RECCNT&amp;amp;siteid=us%2Fdev&amp;amp;p=1&amp;amp;nq=NEW&amp;amp;qu=INT&amp;amp;IntlSearch=&amp;amp;boolean=PHRASE&amp;amp;ig=01&amp;amp;i=09&amp;amp;i=99&quot;&gt;INT&lt;/a&gt;)))&lt;/pre&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;As normal, rand returns a float/double between 0 and 1.&lt;/p&gt;  </content><link rel='replies' type='application/atom+xml' href='http://rhale78.blogspot.com/feeds/1522731978569880539/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://rhale78.blogspot.com/2011/05/true-random-numbers-in-sql.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/270091469191232126/posts/default/1522731978569880539'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/270091469191232126/posts/default/1522731978569880539'/><link rel='alternate' type='text/html' href='http://rhale78.blogspot.com/2011/05/true-random-numbers-in-sql.html' title='True Random Numbers in SQL'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/09185478558704427023</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-270091469191232126.post-8385319309298782075</id><published>2011-05-16T15:39:00.001-04:00</published><updated>2011-05-17T09:11:23.858-04:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="strings"/><title type='text'>String Equality and Performance in C#</title><content type='html'>Strings in .Net are one of the more used primitives but are also the most problematic performance wise.&amp;nbsp; In college and while learning through books, etc. , we’re told that to concatenate two strings, use the + operator.&amp;nbsp; The + operator seems to become habit fairly quickly and sticks with us, and we wonder why our programs are taking seconds between operations and eating megs of memory.&amp;nbsp; It’s only after running a performance analyzer we realize the culprit – the old standby + operator which is taking seconds to concat two strings.&amp;nbsp; We learn through that that we can increase performance and reduce memory usage by using StringBuilder and its Append method instead and bring seconds down to milliseconds and drop megs off the memory footprint.&amp;nbsp; While this may not be the fastest method out there, it sure beats the + operator that we get into the habit of using.&lt;br&gt;We’re also told to use the == operator (or .equals in Java) for string equality.&amp;nbsp; Is == the best operator to use when doing string equality operations?&amp;nbsp; And, is there a fast case-insensitive way to do string equality?&lt;br&gt;As usual, there’s more than one way to do a task in .Net and string equality is no exception.&amp;nbsp; I counted at least 24 different ways using the .Net built-in methods.&amp;nbsp; A lot of the different ways come from doing string comparisons and doing the comparisons based on culture (Windows-installed, current, etc) or on doing a binary comparison…speed is also determined based on whether you’re doing a culture-specific comparison or doing a simple binary comparison (i.e. via ASCII/Unicode-table).&amp;nbsp; Sting equality is not exactly the same as string comparisons so I’m ignoring culture in this post, with the exception of which performs the best given the circumstances.&lt;br&gt;Grouping the equality operations together without their culture options, there are 6.&amp;nbsp; The == operator, .equals, .CompareTo, the static methods string.equals, string.Compare, and string.CompareOrdinal.&lt;br&gt;Since, in general, string equality operations are very fast when done as a single operation, I’ve ran tests based on 6,250,000 (2,500&lt;sup&gt;2&lt;/sup&gt;) string equality tests.&amp;nbsp; For these tests, I have a routine to create 2,500 randomly-generated strings.&amp;nbsp; I tested with string lengths between 1 and 1k (1024).&lt;br&gt;Ok, so the answer to which is faster – well, guess what, it depends.&amp;nbsp; [nothing is ever as easy as it seems, is it?].&amp;nbsp; The answer is different depending on if you’re dealing with same-length strings vs different length strings, and on whether you’re wanting to ignore case or not.&amp;nbsp; There are sure to be other reasons for the speed difference as well but here’re my results.&amp;nbsp; I’ll do the comparison based on different vs same length strings – just use the best function listed for whether to ignore the case or not.&lt;br&gt; &lt;h2&gt;DIFFERENT Length Strings&lt;/h2&gt;.equals and string.equals seem to be pretty much tied for 1st and 2nd place with time around .09 seconds (the .Net timer object I was using for the time calculation has an accuracy to .001 seconds).&amp;nbsp; Both of these are using ordinal ignore case comparison. &lt;br&gt;Here’s the other results for comparison:&lt;br&gt; &lt;table style=&quot;width: 373px&quot; border=&quot;1&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot;&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td valign=&quot;top&quot; width=&quot;280&quot;&gt;.equals (ordinal ignore case)&lt;/td&gt; &lt;td valign=&quot;top&quot; width=&quot;91&quot;&gt;.097&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign=&quot;top&quot; width=&quot;277&quot;&gt;string.equals (ordinal ignore case)&lt;/td&gt; &lt;td valign=&quot;top&quot; width=&quot;94&quot;&gt;.098&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign=&quot;top&quot; width=&quot;275&quot;&gt;.equals (ordinal)&lt;/td&gt; &lt;td valign=&quot;top&quot; width=&quot;96&quot;&gt;.120&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign=&quot;top&quot; width=&quot;273&quot;&gt;.equals&lt;/td&gt; &lt;td valign=&quot;top&quot; width=&quot;98&quot;&gt;.121&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign=&quot;top&quot; width=&quot;272&quot;&gt;string.equals (ordinal)&lt;/td&gt; &lt;td valign=&quot;top&quot; width=&quot;99&quot;&gt;.127&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign=&quot;top&quot; width=&quot;271&quot;&gt;==&lt;/td&gt; &lt;td valign=&quot;top&quot; width=&quot;100&quot;&gt;.135&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign=&quot;top&quot; width=&quot;270&quot;&gt;string.CompareOrdinal&lt;/td&gt; &lt;td valign=&quot;top&quot; width=&quot;101&quot;&gt;.239&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign=&quot;top&quot; width=&quot;270&quot;&gt;.equals (invariant culture)&lt;/td&gt; &lt;td valign=&quot;top&quot; width=&quot;101&quot;&gt;.627&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign=&quot;top&quot; width=&quot;270&quot;&gt;.equals (invariant ignore case)&lt;/td&gt; &lt;td valign=&quot;top&quot; width=&quot;101&quot;&gt;.635&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign=&quot;top&quot; width=&quot;270&quot;&gt;string.compare (ignore case)&lt;/td&gt; &lt;td valign=&quot;top&quot; width=&quot;101&quot;&gt;.658&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign=&quot;top&quot; width=&quot;270&quot;&gt;.equals (current culture ignore case)&lt;/td&gt; &lt;td valign=&quot;top&quot; width=&quot;101&quot;&gt;.659&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign=&quot;top&quot; width=&quot;270&quot;&gt;string.compare&lt;/td&gt; &lt;td valign=&quot;top&quot; width=&quot;101&quot;&gt;.660&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign=&quot;top&quot; width=&quot;270&quot;&gt;string.equals (current culture ignore case)&lt;/td&gt; &lt;td valign=&quot;top&quot; width=&quot;101&quot;&gt;.673&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign=&quot;top&quot; width=&quot;270&quot;&gt;string.equals (invariant ignore case)&lt;/td&gt; &lt;td valign=&quot;top&quot; width=&quot;101&quot;&gt;.676&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign=&quot;top&quot; width=&quot;270&quot;&gt;string.equals (current culture)&lt;/td&gt; &lt;td valign=&quot;top&quot; width=&quot;101&quot;&gt;.682&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign=&quot;top&quot; width=&quot;270&quot;&gt;.CompareTo&lt;/td&gt; &lt;td valign=&quot;top&quot; width=&quot;101&quot;&gt;.684&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign=&quot;top&quot; width=&quot;270&quot;&gt;.equals (current culture)&lt;/td&gt; &lt;td valign=&quot;top&quot; width=&quot;101&quot;&gt;.689&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign=&quot;top&quot; width=&quot;270&quot;&gt;== (w/ ToLowerInvariant inline)&lt;/td&gt; &lt;td valign=&quot;top&quot; width=&quot;101&quot;&gt;24.153 (yes, seconds)&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign=&quot;top&quot; width=&quot;270&quot;&gt;== (w/ ToUpper inline)&lt;/td&gt; &lt;td valign=&quot;top&quot; width=&quot;101&quot;&gt;25.071&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign=&quot;top&quot; width=&quot;270&quot;&gt;== (w/ ToUpper external)&lt;/td&gt; &lt;td valign=&quot;top&quot; width=&quot;101&quot;&gt;25.029&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign=&quot;top&quot; width=&quot;270&quot;&gt;== (w/ ToLower inline)&lt;/td&gt; &lt;td valign=&quot;top&quot; width=&quot;101&quot;&gt;25.504&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign=&quot;top&quot; width=&quot;270&quot;&gt;== (w/ ToLower external)&lt;/td&gt; &lt;td valign=&quot;top&quot; width=&quot;102&quot;&gt;25.730&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt; &lt;h2&gt;&amp;nbsp;&lt;/h2&gt; &lt;h2&gt;SAME Length Strings&lt;/h2&gt;For same length strings, things are slightly different – string.equals (ordinal) and .equals (ordinal) are at the top, not the ordinal ignore case.&amp;nbsp; Here’s the rundown for same length strings.&amp;nbsp; I’ve omitted the ToLower/ToUpper results as they were just horrible in performance.&lt;br&gt; &lt;table style=&quot;width: 372px&quot; border=&quot;1&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot;&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td valign=&quot;top&quot; width=&quot;311&quot;&gt;string.Equals (ordinal)&lt;/td&gt; &lt;td valign=&quot;top&quot; width=&quot;59&quot;&gt;.124&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign=&quot;top&quot; width=&quot;307&quot;&gt;.equals (ordinal)&lt;/td&gt; &lt;td valign=&quot;top&quot; width=&quot;63&quot;&gt;.128&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign=&quot;top&quot; width=&quot;304&quot;&gt;string.compareOrdinal&lt;/td&gt; &lt;td valign=&quot;top&quot; width=&quot;66&quot;&gt;.132&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign=&quot;top&quot; width=&quot;302&quot;&gt;.equals&lt;/td&gt; &lt;td valign=&quot;top&quot; width=&quot;68&quot;&gt;.133&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign=&quot;top&quot; width=&quot;301&quot;&gt;==&lt;/td&gt; &lt;td valign=&quot;top&quot; width=&quot;69&quot;&gt;.146&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign=&quot;top&quot; width=&quot;300&quot;&gt;.equals (ordinal ignore case)&lt;/td&gt; &lt;td valign=&quot;top&quot; width=&quot;70&quot;&gt;.213&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign=&quot;top&quot; width=&quot;299&quot;&gt;string.Equals (ordinal ignore case)&lt;/td&gt; &lt;td valign=&quot;top&quot; width=&quot;71&quot;&gt;.230&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign=&quot;top&quot; width=&quot;299&quot;&gt;string.Equals (invariant culture ignore case)&lt;/td&gt; &lt;td valign=&quot;top&quot; width=&quot;71&quot;&gt;.577&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign=&quot;top&quot; width=&quot;299&quot;&gt;string.Equals (invariant culture)&lt;/td&gt; &lt;td valign=&quot;top&quot; width=&quot;71&quot;&gt;.578&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign=&quot;top&quot; width=&quot;299&quot;&gt;.equals (invariant culture ignore case)&lt;/td&gt; &lt;td valign=&quot;top&quot; width=&quot;71&quot;&gt;.611&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign=&quot;top&quot; width=&quot;299&quot;&gt;string.Equals (current culture ignore case)&lt;/td&gt; &lt;td valign=&quot;top&quot; width=&quot;71&quot;&gt;.620&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign=&quot;top&quot; width=&quot;299&quot;&gt;.equals (current culture)&lt;/td&gt; &lt;td valign=&quot;top&quot; width=&quot;71&quot;&gt;.622&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign=&quot;top&quot; width=&quot;299&quot;&gt;string.Equals (current culture)&lt;/td&gt; &lt;td valign=&quot;top&quot; width=&quot;71&quot;&gt;.630&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign=&quot;top&quot; width=&quot;299&quot;&gt;.CompareTo&lt;/td&gt; &lt;td valign=&quot;top&quot; width=&quot;71&quot;&gt;.634&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign=&quot;top&quot; width=&quot;299&quot;&gt;.equals (invariant culture)&lt;/td&gt; &lt;td valign=&quot;top&quot; width=&quot;71&quot;&gt;.636&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign=&quot;top&quot; width=&quot;299&quot;&gt;string.compare (ignore case)&lt;/td&gt; &lt;td valign=&quot;top&quot; width=&quot;71&quot;&gt;.638&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign=&quot;top&quot; width=&quot;299&quot;&gt;string.compare&lt;/td&gt; &lt;td valign=&quot;top&quot; width=&quot;72&quot;&gt;.686&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt; &lt;h2&gt;&lt;b&gt;&lt;/b&gt;&amp;nbsp;&lt;/h2&gt; &lt;h2&gt;&lt;b&gt;Code&lt;/b&gt; &lt;/h2&gt;Ok, so you don’t want to look up how to do an ordinal ignore case equality against two strings…well, here’s the code snipets.&amp;nbsp; Variables str1 and str2 are strings.&lt;br&gt; &lt;h4&gt;==&lt;/h4&gt;This one is easy – not much explanation needed.&lt;br&gt;&lt;pre style=&quot;border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 496px; padding-right: 5px; height: 52px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px&quot;&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;1: &lt;span style=&quot;color: blue&quot;&gt;if&lt;/span&gt; (str1 == str2)&lt;/pre&gt;&lt;/pre&gt;&lt;br&gt;&lt;br /&gt;&lt;h4&gt;.Equals&lt;/h4&gt;&lt;br&gt;String object method – similar to Java’s equals method.&lt;br&gt;&lt;pre style=&quot;border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 496px; padding-right: 5px; height: 52px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px&quot;&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;1: &lt;span style=&quot;color: blue&quot;&gt;if&lt;/span&gt; (str1.Equals(str2))&lt;/pre&gt;&lt;/pre&gt;&lt;br&gt;&lt;br /&gt;&lt;h4&gt;string.Compare&lt;/h4&gt;&lt;br&gt;One of the static string compare functions.&amp;nbsp; Returns 0 if strings are equal.&amp;nbsp; Several options available.&lt;br&gt;&lt;pre style=&quot;border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 496px; padding-right: 5px; height: 52px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px&quot;&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;1: &lt;span style=&quot;color: blue&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: blue&quot;&gt;string&lt;/span&gt;.Compare(str1, str2) == 0)&lt;/pre&gt;&lt;/pre&gt;&lt;br&gt;&lt;br /&gt;&lt;h4&gt;string.CompareOrdinal&lt;/h4&gt;&lt;br&gt;Another static string compare function – compares using binary comparison instead of text so it uses the ASCII/Unicode table for its comparison.&lt;br&gt;&lt;pre style=&quot;border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 496px; padding-right: 5px; height: 52px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px&quot;&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;1: &lt;span style=&quot;color: blue&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: blue&quot;&gt;string&lt;/span&gt;.CompareOrdinal(str1, str2) == 0)&lt;/pre&gt;&lt;/pre&gt;&lt;br&gt;&lt;br /&gt;&lt;h4&gt;string.Compare (ignore case)&lt;/h4&gt;&lt;br&gt;An overload to string.Compare that ignores case of the characters.&lt;br&gt;&lt;pre style=&quot;border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 495px; padding-right: 5px; height: 52px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px&quot;&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;1: &lt;span style=&quot;color: blue&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: blue&quot;&gt;string&lt;/span&gt;.Compare(str1, str2,&lt;span style=&quot;color: blue&quot;&gt;true&lt;/span&gt;) == 0)&lt;/pre&gt;&lt;/pre&gt;&lt;br&gt;&lt;br /&gt;&lt;h4&gt;string.Equals, .Equals (current culture)&lt;/h4&gt;&lt;br&gt;Compares strings using the current machine/user’s culture).&amp;nbsp; Overload of the equals method.&lt;br&gt;&lt;pre style=&quot;border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 497px; padding-right: 5px; height: 52px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px&quot;&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;1: &lt;span style=&quot;color: blue&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: blue&quot;&gt;string&lt;/span&gt;.Equals(str1, str2,StringComparison.CurrentCulture))&lt;/pre&gt;&lt;/pre&gt;&lt;pre style=&quot;border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 495px; padding-right: 5px; height: 52px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px&quot;&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;1: &lt;span style=&quot;color: blue&quot;&gt;if&lt;/span&gt; (str1.Equals(str2,StringComparison.CurrentCulture))&lt;/pre&gt;&lt;/pre&gt;&lt;b&gt;string.Equals, .Equals (current culture ignore case) &lt;/b&gt;&lt;br&gt;Same as equals current culture – just ignores case&lt;br&gt;&lt;pre style=&quot;border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 496px; padding-right: 5px; height: 52px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px&quot;&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;1: &lt;span style=&quot;color: blue&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: blue&quot;&gt;string&lt;/span&gt;.Equals(str1, str2, StringComparison.CurrentCultureIgnoreCase))&lt;/pre&gt;&lt;/pre&gt;&lt;pre style=&quot;border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 498px; padding-right: 5px; height: 52px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px&quot;&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;1: &lt;span style=&quot;color: blue&quot;&gt;if&lt;/span&gt; (str1.Equals(str2, StringComparison.CurrentCultureIgnoreCase))&lt;/pre&gt;&lt;/pre&gt;&lt;br&gt;&lt;br /&gt;&lt;h4&gt;string.Equals, .Equals (invariant culture)&lt;/h4&gt;&lt;br&gt;Compares based on the installed Windows culture.&lt;br&gt;&lt;pre style=&quot;border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 496px; padding-right: 5px; height: 52px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px&quot;&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;1: &lt;span style=&quot;color: blue&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: blue&quot;&gt;string&lt;/span&gt;.Equals(str1, str2, StringComparison.InvariantCulture))&lt;/pre&gt;&lt;/pre&gt;&lt;pre style=&quot;border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 498px; padding-right: 5px; height: 52px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px&quot;&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;1: &lt;span style=&quot;color: blue&quot;&gt;if&lt;/span&gt; (str1.Equals(str2, StringComparison.InvariantCulture))&lt;/pre&gt;&lt;/pre&gt;&lt;br&gt;&lt;br /&gt;&lt;h4&gt;string.Equals, .Equals (invariant culture ignore case)&lt;/h4&gt;&lt;br&gt;Ignores case but compares on the currently installed Windows culture.&lt;br&gt;&lt;pre style=&quot;border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 496px; padding-right: 5px; height: 52px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px&quot;&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;1: &lt;span style=&quot;color: blue&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: blue&quot;&gt;string&lt;/span&gt;.Equals(str1, str2, StringComparison.InvariantCultureIgnoreCase))&lt;/pre&gt;&lt;/pre&gt;&lt;pre style=&quot;border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 496px; padding-right: 5px; height: 52px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px&quot;&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;1: &lt;span style=&quot;color: blue&quot;&gt;if&lt;/span&gt; (str1.Equals(str2, StringComparison.InvariantCultureIgnoreCase))&lt;/pre&gt;&lt;/pre&gt;&lt;br&gt;&lt;br /&gt;&lt;h4&gt;string.Equals, .Equals (ordinal)&lt;/h4&gt;&lt;br&gt;Performs binary (ASCII/Unicode) comparison.&lt;br&gt;&lt;pre style=&quot;border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 496px; padding-right: 5px; height: 52px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px&quot;&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;1: &lt;span style=&quot;color: blue&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: blue&quot;&gt;string&lt;/span&gt;.Equals(str1, str2, StringComparison.Ordinal))&lt;/pre&gt;&lt;/pre&gt;&lt;pre style=&quot;border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 495px; padding-right: 5px; height: 52px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px&quot;&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;1: &lt;span style=&quot;color: blue&quot;&gt;if&lt;/span&gt; (str1.Equals(str2, StringComparison.Ordinal))&lt;/pre&gt;&lt;/pre&gt;&lt;br&gt;&lt;br /&gt;&lt;h4&gt;string.Equals, .Equals (ordinal ignore case)&lt;/h4&gt;&lt;br&gt;Binary comparison but ignores case.&lt;br&gt;&lt;pre style=&quot;border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 497px; padding-right: 5px; height: 52px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px&quot;&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;1: &lt;span style=&quot;color: blue&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: blue&quot;&gt;string&lt;/span&gt;.Equals(str1, str2, StringComparison.OrdinalIgnoreCase))&lt;/pre&gt;&lt;/pre&gt;&lt;pre style=&quot;border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 495px; padding-right: 5px; height: 52px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px&quot;&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;1: &lt;span style=&quot;color: blue&quot;&gt;if&lt;/span&gt; (str1.Equals(str2, StringComparison.OrdinalIgnoreCase))&lt;/pre&gt;&lt;/pre&gt;&lt;br&gt;&lt;br /&gt;&lt;h4&gt;.CompareTo&lt;/h4&gt;&lt;br&gt;String object compare to method – similar to string compare method except no overloads other than comparing strings to objects.&lt;br&gt;&lt;pre style=&quot;border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 495px; padding-right: 5px; height: 52px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px&quot;&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;1: &lt;span style=&quot;color: blue&quot;&gt;if&lt;/span&gt; (str1.CompareTo(str2) == 0)&lt;/pre&gt;&lt;/pre&gt;&lt;br&gt;&lt;br /&gt;&lt;h4&gt;== (w/ ToLower), == (w/ ToUpper), == (ToLowerInvariant)&lt;/h4&gt;&lt;br&gt;Sadly, this is how I’ve done case insensitive searches for years (even in .Net) thanks for my many years programming in BASIC and QuickBasic – neither of which had the many ways to do string equality that .Net has.&amp;nbsp; This is also, sadly, one of the slowest ways to do string case insensitive equality.&amp;nbsp; The true cost here is the ToLower case conversion, which is just slow.&amp;nbsp; This, just like the + operator for strings, is one of those “don’t do these” features of strings.&amp;nbsp; If you’re needing to do case insensitive equality, use something else…&lt;br&gt;&lt;pre style=&quot;border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 495px; padding-right: 5px; height: 52px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px&quot;&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;1: &lt;span style=&quot;color: blue&quot;&gt;if&lt;/span&gt; (str1.ToLower()==str2.ToLower())&lt;/pre&gt;&lt;/pre&gt;&lt;pre style=&quot;border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 496px; padding-right: 5px; height: 52px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px&quot;&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;1: &lt;span style=&quot;color: blue&quot;&gt;if&lt;/span&gt; (str1.ToUpper() == str2.ToUpper())&lt;/pre&gt;&lt;/pre&gt;&lt;pre style=&quot;border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 496px; padding-right: 5px; height: 52px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px&quot;&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;1: &lt;span style=&quot;color: blue&quot;&gt;if&lt;/span&gt; (str1.ToLowerInvariant() == str2.ToLowerInvariant())&lt;/pre&gt;&lt;/pre&gt;&lt;br&gt;&lt;br /&gt;&lt;h4&gt;== (w/ ToLower external), == (w/ ToUpper external)&lt;/h4&gt;&lt;br&gt;Essentially the only difference here is ToLower is pulled outside of the equality – so essentially the case conversion is done elsewhere…still takes a LOT of time to do the conversion on top of the equality.&lt;br&gt;&lt;pre style=&quot;border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 495px; padding-right: 5px; height: 108px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px&quot;&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;1: &lt;span style=&quot;color: blue&quot;&gt;string&lt;/span&gt; a = str1.ToUpper();&lt;br&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;2: &lt;span style=&quot;color: blue&quot;&gt;string&lt;/span&gt; b = str2.ToUpper();&lt;br&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px&quot;&gt;3: &lt;span style=&quot;color: blue&quot;&gt;if&lt;/span&gt; (a == b)&lt;/pre&gt;&lt;/pre&gt;&lt;br&gt;&lt;br /&gt;&lt;h2&gt;Conclusion&lt;/h2&gt;&lt;br&gt;Well, since most strings in .Net (and Java) are different length strings, it’s best to use .equals over the == operator.&amp;nbsp; If the program does not care about case nor culture comparisons, adding in the case insensitive ordinal comparison also helps as well.&amp;nbsp; Of course, the performance is minor in comparison to the + operator, but, if you’re dealing with millions (or billions) of string equalities, every millisecond gained helps.&amp;nbsp; Definitely avoid use of ToLower or ToUpper to do comparisons/equality.&lt;br /&gt;  </content><link rel='replies' type='application/atom+xml' href='http://rhale78.blogspot.com/feeds/8385319309298782075/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://rhale78.blogspot.com/2011/05/string-equality-and-performance-in-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/270091469191232126/posts/default/8385319309298782075'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/270091469191232126/posts/default/8385319309298782075'/><link rel='alternate' type='text/html' href='http://rhale78.blogspot.com/2011/05/string-equality-and-performance-in-c.html' title='String Equality and Performance in C#'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/09185478558704427023</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-270091469191232126.post-6266513759493220074</id><published>2011-05-09T15:12:00.038-04:00</published><updated>2011-05-09T15:28:19.556-04:00</updated><category scheme="http://www.blogger.com/atom/ns#" term=".Net 4.0"/><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="comma delimited lists"/><category scheme="http://www.blogger.com/atom/ns#" term="string.Join"/><category scheme="http://www.blogger.com/atom/ns#" term="StringBuilder"/><title type='text'>Easy Separated Lists in .Net</title><content type='html'>&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background: none repeat scroll 0% 0% white; font-family: Verdana,sans-serif; line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;&lt;span style=&quot;color: black; font-size: 10pt;&quot;&gt;Found a simple way of doing a separated list, similar to&amp;nbsp;PHP&#39;s &lt;a href=&quot;http://php.net/manual/en/function.implode.php&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;implode function&lt;/span&gt;&lt;/a&gt;. The code expects the variable&amp;nbsp;&quot;Values&quot; to be of an IEnumerable type, which includes arrays, lists, etc.&amp;nbsp; Very useful for doing comma delimited lists.&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background: none repeat scroll 0% 0% white; font-family: Verdana,sans-serif; line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background: none repeat scroll 0% 0% white; font-family: Verdana,sans-serif; line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;&lt;span style=&quot;color: black; font-size: 10pt;&quot;&gt;Instead of doing:&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background: none repeat scroll 0% 0% white; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace; line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;&lt;span style=&quot;color: blue; font-size: 10pt;&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 10pt;&quot;&gt; commaList =&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #a31515; font-size: 10pt;&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 10pt;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background: none repeat scroll 0% 0% white; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace; line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background: none repeat scroll 0% 0% white; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace; line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;&lt;span style=&quot;color: blue; font-size: 10pt;&quot;&gt;foreach&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 10pt;&quot;&gt;&amp;nbsp;(&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 10pt;&quot;&gt;string &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 10pt;&quot;&gt;value &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 10pt;&quot;&gt;in&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 10pt;&quot;&gt; Values)&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background: none repeat scroll 0% 0% white; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace; line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;&lt;span style=&quot;color: black; font-size: 10pt;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background: none repeat scroll 0% 0% white; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace; line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;&lt;span style=&quot;color: black; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; commaList = commaList + value;&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background: none repeat scroll 0% 0% white; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace; line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;&lt;span style=&quot;color: black; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; commaList = commaList +&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #a31515; font-size: 10pt;&quot;&gt;&quot;,&amp;nbsp;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 10pt;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background: none repeat scroll 0% 0% white; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace; line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;&lt;span style=&quot;color: black; font-size: 10pt;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background: none repeat scroll 0% 0% white; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace; line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;&lt;span style=&quot;color: black; font-size: 10pt;&quot;&gt;commaList = commaList.Substring(0, commaList .Length&amp;nbsp;-&amp;nbsp;2);&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background: none repeat scroll 0% 0% white; font-family: Verdana,sans-serif; line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background: none repeat scroll 0% 0% white; font-family: Verdana,sans-serif; line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;&lt;span style=&quot;color: black; font-size: 10pt;&quot;&gt;It&#39;s easier (and faster) to do (.Net 4.0):&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background: none repeat scroll 0% 0% white; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace; line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;&lt;span style=&quot;color: blue; font-size: 10pt;&quot;&gt;string &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 10pt;&quot;&gt;commaList=&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 10pt;&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 10pt;&quot;&gt;.Join(&lt;/span&gt;&lt;span style=&quot;color: #a31515; font-size: 10pt;&quot;&gt;&quot;,&amp;nbsp;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 10pt;&quot;&gt;, Values);&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background: none repeat scroll 0% 0% white; font-family: Verdana,sans-serif; line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background: none repeat scroll 0% 0% white; font-family: Verdana,sans-serif; line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;&lt;span style=&quot;color: black; font-size: 10pt;&quot;&gt;.Net 3/3.5:&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background: none repeat scroll 0% 0% white; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace; line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;&lt;span style=&quot;color: blue; font-size: 10pt;&quot;&gt;string &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 10pt;&quot;&gt;commaList=&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 10pt;&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 10pt;&quot;&gt;.Join(&lt;/span&gt;&lt;span style=&quot;color: #a31515; font-size: 10pt;&quot;&gt;&quot;,&amp;nbsp;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 10pt;&quot;&gt;, Values.ToArray());&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background: none repeat scroll 0% 0% white; font-family: Verdana,sans-serif; line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background: none repeat scroll 0% 0% white; font-family: Verdana,sans-serif; line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;&lt;span style=&quot;color: black; font-size: 10pt;&quot;&gt;.Net 2.0:&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background: none repeat scroll 0% 0% white; font-family: Verdana,sans-serif; line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace; font-size: 10pt;&quot;&gt;string &lt;/span&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace; font-size: 10pt;&quot;&gt;commaList=&lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace; font-size: 10pt;&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace; font-size: 10pt;&quot;&gt;.Join(&lt;/span&gt;&lt;span style=&quot;color: #a31515; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace; font-size: 10pt;&quot;&gt;&quot;,&amp;nbsp;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace; font-size: 10pt;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace; font-size: 10pt;&quot;&gt;new &lt;/span&gt;&lt;span style=&quot;color: #2b91af; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace; font-size: 10pt;&quot;&gt;List&lt;/span&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace; font-size: 10pt;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace; font-size: 10pt;&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace; font-size: 10pt;&quot;&gt;&amp;gt;(Values).&lt;/span&gt;&lt;span style=&quot;color: #2b91af; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace; font-size: 10pt;&quot;&gt;ToArray&lt;/span&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace; font-size: 10pt;&quot;&gt;());&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 10pt;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background: none repeat scroll 0% 0% white; font-family: Verdana,sans-serif; line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background: none repeat scroll 0% 0% white; font-family: Verdana,sans-serif; line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;&lt;span style=&quot;color: black; font-size: 10pt;&quot;&gt;Of course the join function allows any separator to be used,&amp;nbsp;not just &quot;, &quot;.&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background: none repeat scroll 0% 0% white; font-family: Verdana,sans-serif; line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;&lt;span style=&quot;color: black; font-size: 10pt;&quot;&gt;And, according to this &lt;a href=&quot;http://stackoverflow.com/revisions/8b1bf8a0-8b9a-4386-88d7-1fdd21d8f674/view-source&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;post&lt;/span&gt;&lt;/a&gt;, string.Join is faster than StringBuilder in this particular case.&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;
&lt;pre style=&quot;background: none repeat scroll 0% 0% white; color: black; font-family: Verdana,sans-serif; font-size: 13px;&quot;&gt;&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://rhale78.blogspot.com/feeds/6266513759493220074/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://rhale78.blogspot.com/2011/05/easy-separated-lists-in-net.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/270091469191232126/posts/default/6266513759493220074'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/270091469191232126/posts/default/6266513759493220074'/><link rel='alternate' type='text/html' href='http://rhale78.blogspot.com/2011/05/easy-separated-lists-in-net.html' title='Easy Separated Lists in .Net'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/09185478558704427023</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-270091469191232126.post-7899159572130974383</id><published>2010-02-26T17:54:00.000-05:00</published><updated>2010-02-26T17:54:00.276-05:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Intro to Computer Programming"/><title type='text'>Intro to Computer Programming - Chapter 7: Making Decisions</title><content type='html'>&lt;span xmlns=&quot;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;h2&gt;&lt;span xmlns=&quot;&quot;&gt;Introduction&lt;br /&gt;
&lt;/span&gt;&lt;/h2&gt;&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;The human life is filled with decisions.  Every day, we as humans make millions of decisions, everything from when to get up to what to eat and each of those decisions brings on even more decisions.  If we decide that we want something to eat, we must decide what we want to eat, where we&#39;re going to get it from, whether we are going to cook it ourselves or go get it from somewhere, how we want it cooked, if we have enough money to buy it, if we have enough time to eat it, and so forth.  We make decisions based on our past experiences and our personal preferences.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Computers are very good at making decisions.  Computers make decisions, but their decisions are usually based on the content of a variable or the value of an expression instead of the computer&#39;s past experiences [unless of course you&#39;re dealing with artificial intelligence and then it&#39;s still based on variables].&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Computers have several different decision making statements.  These statements can be classified into two categories, a branch and a loop.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;h2&gt;&lt;span xmlns=&quot;&quot;&gt;Branch Statements&lt;br /&gt;
&lt;/span&gt;&lt;/h2&gt;&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Humans use branch statements daily on common decision making tasks.  For instance, the decision whether a person has enough money to buy a particular item is considered to be a branch statement.  The reason this is considered to be a branch statement is because if the person does not have enough money to buy the item then the person could buy a cheaper item or do something else.  Basically a branch statement will branch off into two or more courses of action, depending upon the decision.  Branch statements in English usually use the words if, then, and else.  &lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Branch statements in computers are very similar to those in English.  Almost all computer languages have some form of a branch statement, most using the same word if to mark that a statement is a branch statement.  For example, if the user pressed the &quot;a&quot; key, then do this else do something else.  Both the Qbasic and the C/C++ language have a form of the branch statement.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;h3&gt;&lt;span xmlns=&quot;&quot;&gt;Branch Statements in Qbasic&lt;br /&gt;
&lt;/span&gt;&lt;/h3&gt;&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;In Qbasic, the form of the branch statement is similar to the form in the English language in that it uses if-then-else.  The if statement is followed by an expression that could have the value of true or false, if the expression is false then the computer does what comes after the then part of the statement and ignores the else part of the statement, otherwise it will ignore the then part of the statement and does the else part of the statement instead.  The else part of the statement can be left alone if there is nothing to be done.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;A good example of this is how the absolute function works.  The absolute value function checks to see if a number is less than 0, if it is then it takes the negative of that number [which makes it positive since the number is already negative], otherwise it leaves the number alone.  So, the statement would be &lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;IF number&amp;lt;0 THEN number=-number&lt;/span&gt;.  Since there is nothing to do if the number is 0 or greater, the else part of the statement is left off.  The type of if statement shown here is considered to be a simple if statement since it only includes at most one command on the then branch and at most one command on the else branch.  The following program illustrates the if statement.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;table border=&quot;0&quot; style=&quot;border-collapse: collapse;&quot;&gt;&lt;colgroup&gt;&lt;col style=&quot;width: 437px;&quot;&gt;&lt;/col&gt;&lt;/colgroup&gt;&lt;tbody valign=&quot;top&quot;&gt;
&lt;tr&gt;&lt;td style=&quot;border: 0.5pt solid; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;IF a=1 THEN PRINT &quot;Hello&quot;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;IF a=1 THEN PRINT &quot;Hello&quot; ELSE PRINT &quot;Bye&quot;&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;IF a=1 THEN ELSE PRINT &quot;Bye&quot;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;b&gt;Program 19 - Qbasic IF Example&lt;br /&gt;
&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;The other type of if statement is called a block if statement.  The block if statement can have multiple commands on either the then branch or the else branch or both.  The way to do a block if statement is to do the if statement as normal up to and including the then, then doing the program as normal with each statement on a line by itself, then when the block is done either do the else statement or tell the computer that this is the end of the if by including the statement end if.  The following example demonstrates a block if with the block on the then, the block on the else, and the block on both.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;table border=&quot;0&quot; style=&quot;border-collapse: collapse;&quot;&gt;&lt;colgroup&gt;&lt;col style=&quot;width: 370px;&quot;&gt;&lt;/col&gt;&lt;/colgroup&gt;&lt;tbody valign=&quot;top&quot;&gt;
&lt;tr&gt;&lt;td style=&quot;border: 0.5pt solid; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;IF number&amp;lt;0 THEN&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;        PRINT &quot;Number is negative.&quot;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;        number=-number&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;ELSE&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;        PRINT &quot;Number is positive.&quot;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;END IF&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;IF number&amp;lt;0 THEN&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;        PRINT &quot;Number is negative.&quot;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;ELSE&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;        PRINT &quot;Number is positive.&quot;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;        number=2*number&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;END IF&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;IF number&amp;lt;0 THEN&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;        PRINT &quot;Number is negative.&quot;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;        number=-number&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;ELSE&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;        PRINT &quot;Number is positive.&quot;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;        number=2*number&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;END IF&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;b&gt;Program 20 - Qbasic Block IF Example&lt;br /&gt;
&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;If statements can also be compound or nested and contain other if statements within them.  The only caution here is that the programmer must make sure to close each block if statement by using the end if statement.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Block if statements are also allowed to change the expression for each else statement included in the if.  For example, if the programmer wanted to see if a&amp;gt;1 and if that was false then to check if c&amp;lt;0, that could be accomplished by using a compound if or by using the elseif command.  Program 21 demonstrates the use of the compound if and also the use of the eleseif command.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;table border=&quot;0&quot; style=&quot;border-collapse: collapse;&quot;&gt;&lt;colgroup&gt;&lt;col style=&quot;width: 360px;&quot;&gt;&lt;/col&gt;&lt;/colgroup&gt;&lt;tbody valign=&quot;top&quot;&gt;
&lt;tr&gt;&lt;td style=&quot;border: 0.5pt solid; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;IF x&amp;gt;0 AND x&amp;lt;50 THEN&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;        IF y&amp;gt;0 AND y&amp;lt;50 THEN&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;                PRINT z&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;        ELSE&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;                PRINT x*y&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;        END IF&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;ELSE&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;        IF z&amp;gt;0 AND z&amp;lt;10 THEN&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;                PRINT y&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;        ELSE&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;                IF a=1 THEN&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;                       PRINT x,y,z&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;                END IF&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;        END IF&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;END IF&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;IF x&amp;gt;0 AND x&amp;lt;50 THEN&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;        IF y&amp;gt;0 AND y&amp;lt;50 THEN&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;                PRINT z&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;        ELSE&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;                PRINT x*y&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;        END IF&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;ELSE&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;        IF z&amp;gt;0 AND z&amp;lt;10 THEN&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;                PRINT y&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;        ELSEIF a=1 THEN&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;                PRINT x,y,z&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;        END IF&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;END IF&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;b&gt;Program 21-Qbasic Compund If example&lt;br /&gt;
&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;h3&gt;&lt;span xmlns=&quot;&quot;&gt;Branch Statements in C/C++&lt;br /&gt;
&lt;/span&gt;&lt;/h3&gt;&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Simple if statements in C/C++ are very similar to simple if statements in Qbasic.  The only differences between C/C++&#39;s simple if statements and Qbasics are that in C/C++, the expression must be enclosed in a set of parenthesis ( () ), and also that the word then is omitted.  Also, as usual in C/C++, a semicolon is added to the end of the line.  Also, there is no difference between the C version of an if statement and the C++ version.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Unlike most statements and functions covered so far in the C/C++ language, the if statement does not require an include file as the if statement is part of the language.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;The following table illustrates the differences between the Qbasic simple if statement and the C/C++ version of the simple if statement.  Note that the output commands are C++ output commands for simplicity and endl is not included.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;table border=&quot;0&quot; style=&quot;border-collapse: collapse;&quot;&gt;&lt;colgroup&gt;&lt;col style=&quot;width: 290px;&quot;&gt;&lt;/col&gt;&lt;col style=&quot;width: 282px;&quot;&gt;&lt;/col&gt;&lt;/colgroup&gt;&lt;tbody valign=&quot;top&quot;&gt;
&lt;tr&gt;&lt;td style=&quot;border: 0.5pt solid; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;b&gt;Qbasic&lt;/b&gt;&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: solid solid solid none; border-width: 0.5pt 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;b&gt;C/C++&lt;/b&gt;&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 10pt;&quot;&gt;IF a=1 THEN PRINT a&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 10pt;&quot;&gt;if (a==1) cout&amp;lt;&amp;lt;a;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 10pt;&quot;&gt;IF a=5 THEN PRINT a ELSE PRINT b&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 10pt;&quot;&gt;if (a==5) cout&amp;lt;&amp;lt;a else cout&amp;lt;&amp;lt;b;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;b&gt;Table 26 – Comparison of Qbasic and C/C++ Simple if statement&lt;br /&gt;
&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Block if statements in C/C++ are also similar to the Qbasic block if statements except that the form of a block in C/C++ is different.  In C/C++, a block is defined as a sequence of programming statements that are between a set of braces ( { } ).  What this means is that C/C++ does not require a end if statement, but instead requires that a program block be created.  The following C++ code segments illustrate the block if in C/C++.  Notice how the line that contains the if does not require a semicolon [if the line is broken between the parenthised expression and the next command], even though it is on a line by itself, also the else is the same way and does not require a semicolon.  Also, notice how if only one command follows the if or the else, it does not require the braces, but if it has more than one command following it it does require the braces.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;table border=&quot;0&quot; style=&quot;border-collapse: collapse;&quot;&gt;&lt;colgroup&gt;&lt;col style=&quot;width: 341px;&quot;&gt;&lt;/col&gt;&lt;/colgroup&gt;&lt;tbody valign=&quot;top&quot;&gt;
&lt;tr&gt;&lt;td style=&quot;border: 0.5pt solid; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;if (number&amp;lt;0)&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;{&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    cout&amp;lt;&amp;lt;&quot;Number is negative.&quot;;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    number=-number;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;}&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;else&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    cout&amp;lt;&amp;lt;&quot;Number is positive.&quot;;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;if (number&amp;lt;0)&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    cout&amp;lt;&amp;lt;&quot;Number is negative.&quot;;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;else&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;{&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    cout&amp;lt;&amp;lt;&quot;Number is positive.&quot;;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    number=2*number;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;}&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;if (number&amp;lt;0)&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;{&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    cout&amp;lt;&amp;lt;&quot;Number is negative.&quot;;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    number=-number;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;}&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;else&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;{&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    cout&amp;lt;&amp;lt;&quot;Number is positive.&quot;;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    number=2*number;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;}&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;b&gt;Program 22 - C/C++ Block if example&lt;br /&gt;
&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;C/C++ also allows compound or nested if statements and these are done the same way as they are in Qbasic.  It is advisable to put nested if statements into their own program block to keep from getting yourself confused as to which else goes with which if.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;As was done in Qbasic, the else if command allows the expression to be changed within the if statement.  The only difference between the else if command in Qbasic and in C/C++ is that else if is two words in C/C++, else if, whereas it is only a single word, elseif, in Qbasic.  The following program illustrates the compound if as well as the else if command.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;table border=&quot;0&quot; style=&quot;border-collapse: collapse;&quot;&gt;&lt;colgroup&gt;&lt;col style=&quot;width: 283px;&quot;&gt;&lt;/col&gt;&lt;/colgroup&gt;&lt;tbody valign=&quot;top&quot;&gt;
&lt;tr&gt;&lt;td style=&quot;border: 0.5pt solid; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;if (x&amp;gt;0&amp;amp;&amp;amp;x&amp;lt;50)&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    if (y&amp;gt;0&amp;amp;&amp;amp;y&amp;lt;50)&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;        cout&amp;lt;&amp;lt;z;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    else&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;        cout&amp;lt;&amp;lt;x*y;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;else&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    if (z&amp;gt;0&amp;amp;&amp;amp;z&amp;lt;10)&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;        cout&amp;lt;&amp;lt;y;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    else&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;        if (a==1)&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;            cout&amp;lt;&amp;lt;x&amp;lt;&amp;lt;y&amp;lt;&amp;lt;z;&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;if (x&amp;gt;0&amp;amp;&amp;amp;x&amp;lt;50)&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    if (y&amp;gt;0&amp;amp;&amp;amp;y&amp;lt;50)&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;        cout&amp;lt;&amp;lt;z;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    else&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;        cout&amp;lt;&amp;lt;x*y;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;else&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    if (z&amp;gt;0&amp;amp;&amp;amp;z&amp;lt;10)&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;        cout&amp;lt;&amp;lt;y;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    else if (a==1)&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;        cout&amp;lt;&amp;lt;x&amp;lt;&amp;lt;y&amp;lt;&amp;lt;z;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;b&gt;Program 23 - C/C++ Compound If Example&lt;br /&gt;
&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;h2&gt;&lt;span xmlns=&quot;&quot;&gt;Loops&lt;br /&gt;
&lt;/span&gt;&lt;/h2&gt;&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Loops are useful in many different type of programs.  A loop gets the computer to repeat a series of steps while something is true, until something is true, a certain number of times, or even infinitely.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Humans use loops on nearly every task we do in our lives.  Walking is performing a loop of taking a series of steps until we reach a certain destination.  Reading is performing a loop within a loop.  With reading, we read the a series of letters until we hit something that tells us that that series of letters is a word, and then we continue to the next word until the end of the sentence or book.  Even speaking is a loop, we speak until we have nothing more to say.  Loops are probably just as common as decisions are as far as humans go.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Computers are no different with the respect to loops.  Some of the most common tasks can only be accomplished by using some form of a loop.  For example, almost all games require some sort of loop that continues until the player wins or loses.  Typing a character on the keyboard requires a loop because the computer has to wait until the user presses a key.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;In Qbasic and in C/C++, there are several types of loops.  There are loops that are used to count (for loops), loops that perform a task while a certain condition is true (do-while and while loops), and loops that perform a task until a condition is true (do-until loops).&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;h3&gt;&lt;span xmlns=&quot;&quot;&gt;For Loops in Qbasic&lt;br /&gt;
&lt;/span&gt;&lt;/h3&gt;&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;One of the easiest ways to get a Qbasic program to count is to use a for loop.  The for loop repeats a series of steps and counts from a given starting value until a given ending value and increases by a given value each time.  For example, the programmer may wish a variable J to count from 1 to 100 and increase by .5 each time through the loop, therefore it would repeat a certain series of steps 200 times.  &lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;The format for the for statement is the word FOR, the variable to be used as a counter along with its initiation, the word TO, then the maximum count (can be a variable or expression), and optionally the word STEP and a step value (can be a variable or expression).  For example, to make a for loop that counts from 1 to 5 and counts by 1 [the default], the for loop should look like: &lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;FOR j=1 TO 5&lt;/span&gt;.  After the for statement there should be a program segment that needs to be repeated the number of times specified by the for loop.  After the program segment should be the command next and the variable name which tells Qbasic where the for loop should end.  This is best explained by the following program which counts from 1 to 10.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;table border=&quot;0&quot; style=&quot;border-collapse: collapse;&quot;&gt;&lt;colgroup&gt;&lt;col style=&quot;width: 178px;&quot;&gt;&lt;/col&gt;&lt;/colgroup&gt;&lt;tbody valign=&quot;top&quot;&gt;
&lt;tr&gt;&lt;td style=&quot;border: 0.5pt solid; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;FOR J=1 TO 10&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;        PRINT J&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;NEXT J&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;b&gt;Program 24 - Simple Qbasic For Loop&lt;br /&gt;
&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;If the programmer wanted to print the numbers from 10 to 1 and count down by -0.5, the program would look like the following:&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;table border=&quot;0&quot; style=&quot;border-collapse: collapse;&quot;&gt;&lt;colgroup&gt;&lt;col style=&quot;width: 283px;&quot;&gt;&lt;/col&gt;&lt;/colgroup&gt;&lt;tbody valign=&quot;top&quot;&gt;
&lt;tr&gt;&lt;td style=&quot;border: 0.5pt solid; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;FOR count=10 TO 1 STEP -.5&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;       PRINT count&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;NEXT count&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;b&gt;Program 25 - Qbasic For loop showing Step Option&lt;br /&gt;
&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Just like if statements, for loops can be nested to perform fairly complex operations.  For example the following program will print a multiplication table from 1 to 5.  Notice how the latest for loop (K) is the one to have the soonest appearing next.  The variable names on the nexts are optional.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;table border=&quot;0&quot; style=&quot;border-collapse: collapse;&quot;&gt;&lt;colgroup&gt;&lt;col style=&quot;width: 293px;&quot;&gt;&lt;/col&gt;&lt;/colgroup&gt;&lt;tbody valign=&quot;top&quot;&gt;
&lt;tr&gt;&lt;td style=&quot;border: 0.5pt solid; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;FOR J=1 to 5&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;        FOR K=1 to 5&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;                 PRINT J*K;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;        NEXT K&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;        PRINT&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;NEXT J&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;&lt;i&gt;1  2  3  4  5&lt;br /&gt;
&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;&lt;i&gt; 2  4  6  8  10&lt;br /&gt;
&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;&lt;i&gt; 3  6  9  12  15&lt;br /&gt;
&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;&lt;i&gt; 4  8  12  16  20&lt;br /&gt;
&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;&lt;i&gt; 5  10  15  20  25&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;b&gt;Program 26 - Nested QBasic For Loop&lt;br /&gt;
&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;For loops can also be used as timing loops by not including a program segment between the for statement and its corresponding next statement.  This technique is sometimes used in games or wherever a program needs to be slower.  As a word of note, this technique is not very stable as the same for loop will run at different speeds on different machines.  For instance, a loop that counts from 1 to 1,000,000 could take several hours on a machine built 5 years ago, but could only take a minute on a modern machine.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;For loops in Qbasic are useful when the maximum count is known, but are not very useful when the maximum count is an unknown value.  Other loops are useful in this case.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;h3&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=270091469191232126&amp;amp;postID=7899159572130974383&quot; name=&quot;tmp&quot;&gt;Do Loops in Qbasic&lt;br /&gt;
&lt;/a&gt;&lt;/span&gt;&lt;/h3&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=270091469191232126&amp;amp;postID=7899159572130974383&quot; name=&quot;tmp&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;In Qbasic, there are several forms of do loops.  There is a do while a condition is true, and also a do until a condition is true.  Each of these loops can be either a test at top or test at bottom loop.  Each of these loops can be used in place of each other, but some are better suited for a particular task.  The do while and do until loops are opposite of each other logically speaking so there is no need to specifically cover them individually but the test at top and test at bottom will next some explanation.&lt;br /&gt;
&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;h4&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=270091469191232126&amp;amp;postID=7899159572130974383&quot; name=&quot;tmp&quot;&gt;Test at Bottom Do Loops&lt;br /&gt;
&lt;/a&gt;&lt;/span&gt;&lt;/h4&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=270091469191232126&amp;amp;postID=7899159572130974383&quot; name=&quot;tmp&quot;&gt;The do loop will continue to execute until a condition is true, or while a condition is true.  The until or while clause must be specified as well as the condition.  The format of the test at bottom do loop is the word do, followed by the sequence of commands to be executed in the loop, then the word loop followed by the clause and then the condition.&lt;br /&gt;
&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=270091469191232126&amp;amp;postID=7899159572130974383&quot; name=&quot;tmp&quot;&gt;In the case of the test at bottom do loops, the loop is allowed to be executed at least once before any testing of the condition is done.  This type of loop could be useful in the case of input from a user and making sure they enter a specific value as is shown in the next program.  As you can see, the two programs are identical except for the changing of until to while and also the &quot;negative&quot; logic where equals changes to not equals other than that, there is no difference in the programs and there is also no difference at all in what the programs do.&lt;br /&gt;
&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;table border=&quot;0&quot; style=&quot;border-collapse: collapse;&quot;&gt;&lt;colgroup&gt;&lt;col style=&quot;width: 370px;&quot;&gt;&lt;/col&gt;&lt;/colgroup&gt;&lt;tbody valign=&quot;top&quot;&gt;
&lt;tr&gt;&lt;td style=&quot;border: 0.5pt solid; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;DO&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;        PRINT &quot;Enter the number 1&quot;;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;        LINE INPUT A$&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;LOOP UNTIL A$=&quot;1&quot;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;DO&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;        PRINT &quot;Enter the number 1&quot;;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;        LINE INPUT A$&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;LOOP WHILE A$&amp;lt;&amp;gt;&quot;1&quot;&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=270091469191232126&amp;amp;postID=7899159572130974383&quot; name=&quot;tmp&quot;&gt;&lt;b&gt;Program 27 - Test at Bottom Do Loop In Qbasic&lt;br /&gt;
&lt;/b&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;h4&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=270091469191232126&amp;amp;postID=7899159572130974383&quot; name=&quot;tmp&quot;&gt;Test at Top Do Loops&lt;br /&gt;
&lt;/a&gt;&lt;/span&gt;&lt;/h4&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=270091469191232126&amp;amp;postID=7899159572130974383&quot; name=&quot;tmp&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Sometimes it is useful to perform a test at the top to prevent a loop from executing.  An example of this would be in a math-related program that must rely on a variable being a certain value before the equation will work [division for instance].  The format of the loop is exactly the opposite of the test at bottom loops, as expected.  The do is followed by the clause and also by the expression and the loop is left by itself.  The following program shows a test at top loop that assumes that an illegal input has been entered beforehand.&lt;br /&gt;
&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;table border=&quot;0&quot; style=&quot;border-collapse: collapse;&quot;&gt;&lt;colgroup&gt;&lt;col style=&quot;width: 331px;&quot;&gt;&lt;/col&gt;&lt;/colgroup&gt;&lt;tbody valign=&quot;top&quot;&gt;
&lt;tr&gt;&lt;td style=&quot;border: 0.5pt solid; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;DO WHILE a$&amp;lt;&amp;gt;&quot;B&quot;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;        PRINT &quot;Incorrect Value&quot;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;        PRINT &quot;Please Press B&quot;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;        LINE INPUT A$&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;LOOP&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;DO UNTIL a$=&quot;B&quot;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;        PRINT &quot;Incorrect Value&quot;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;        PRINT &quot;Please Press B&quot;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;        LINE INPUT A$&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;LOOP&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=270091469191232126&amp;amp;postID=7899159572130974383&quot; name=&quot;tmp&quot;&gt;&lt;b&gt;Program 28 - Test at Top Do Loop in Qbasic&lt;br /&gt;
&lt;/b&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;h4&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=270091469191232126&amp;amp;postID=7899159572130974383&quot; name=&quot;tmp&quot;&gt;While Loops&lt;br /&gt;
&lt;/a&gt;&lt;/span&gt;&lt;/h4&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=270091469191232126&amp;amp;postID=7899159572130974383&quot; name=&quot;tmp&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Qbasic also supplies a while loop, but it is essentially the same as the test at top do while loop.  It is included in the do loops for completeness. &lt;br /&gt;
&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=270091469191232126&amp;amp;postID=7899159572130974383&quot; name=&quot;tmp&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;The format of this loop is similar to the do loops except that the do while is replaced by while and the word loop is replaced by wend [i.e. while end].  This loop is shown below.&lt;br /&gt;
&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;table border=&quot;0&quot; style=&quot;border-collapse: collapse;&quot;&gt;&lt;colgroup&gt;&lt;col style=&quot;width: 331px;&quot;&gt;&lt;/col&gt;&lt;/colgroup&gt;&lt;tbody valign=&quot;top&quot;&gt;
&lt;tr&gt;&lt;td style=&quot;border: 0.5pt solid; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;WHILE a$&amp;lt;&amp;gt;&quot;B&quot;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;        PRINT &quot;Incorrect Value&quot;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;        PRINT &quot;Please Press B&quot;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;        LINE INPUT A$&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;WEND&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;DO WHILE a$&amp;lt;&amp;gt;&quot;B&quot;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;        PRINT &quot;Incorrect Value&quot;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;        PRINT &quot;Please Press B&quot;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;        LINE INPUT A$&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;LOOP&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=270091469191232126&amp;amp;postID=7899159572130974383&quot; name=&quot;tmp&quot;&gt;&lt;b&gt;Program 29 – While Loop in Qbasic&lt;br /&gt;
&lt;/b&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;h3&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=270091469191232126&amp;amp;postID=7899159572130974383&quot; name=&quot;tmp&quot;&gt;Infinite Loops in Qbasic&lt;br /&gt;
&lt;/a&gt;&lt;/span&gt;&lt;/h3&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=270091469191232126&amp;amp;postID=7899159572130974383&quot; name=&quot;tmp&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Infinite loops are useful in many cases and are sometimes done accidentally.  An infinite loop is a loop that never ends and they can be created using any of the Qbasic loops.&lt;br /&gt;
&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=270091469191232126&amp;amp;postID=7899159572130974383&quot; name=&quot;tmp&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;By using a for loop and setting the step equal to zero, an infinite loop can be created.  By using the do-while [top or bottom test], or while-wend loops, a infinite loop can be created by making sure the expression is always true.  By setting the expression to false, the do-until loop also becomes an infinite loop.  The following programs show infinite loops.&lt;br /&gt;
&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;table border=&quot;0&quot; style=&quot;border-collapse: collapse;&quot;&gt;&lt;colgroup&gt;&lt;col style=&quot;width: 235px;&quot;&gt;&lt;/col&gt;&lt;/colgroup&gt;&lt;tbody valign=&quot;top&quot;&gt;
&lt;tr&gt;&lt;td style=&quot;border: 0.5pt solid; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;FOR j=1 to 100 STEP 0&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;NEXT j&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;a=0&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;DO&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;LOOP WHILE a=0&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;DO UNTIL a&amp;lt;&amp;gt;a&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;LOOP&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;WHILE 1&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;WEND&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=270091469191232126&amp;amp;postID=7899159572130974383&quot; name=&quot;tmp&quot;&gt;&lt;b&gt;Program 30 - Infinite Loops in Qbasic&lt;br /&gt;
&lt;/b&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;h3&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=270091469191232126&amp;amp;postID=7899159572130974383&quot; name=&quot;tmp&quot;&gt;Ending Loops Prematurely in Qbasic&lt;br /&gt;
&lt;/a&gt;&lt;/span&gt;&lt;/h3&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=270091469191232126&amp;amp;postID=7899159572130974383&quot; name=&quot;tmp&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;It is sometimes useful to exit a loop before it ends.  For example, if an unexpected error occurred and there was no way to recover, it would be best to exit the loop, let the user know an error occurred and exit the program.  With the exclusion of the while loop, the command exit can be used followed by the type of loop.  The following program illustrates both exiting a for loop as well as a do loop.&lt;br /&gt;
&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;table border=&quot;0&quot; style=&quot;border-collapse: collapse;&quot;&gt;&lt;colgroup&gt;&lt;col style=&quot;width: 302px;&quot;&gt;&lt;/col&gt;&lt;/colgroup&gt;&lt;tbody valign=&quot;top&quot;&gt;
&lt;tr&gt;&lt;td style=&quot;border: 0.5pt solid; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;FOR J=-5 TO 5&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;        IF J=0 THEN EXIT FOR&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;        PRINT 20/J;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;NEXT J&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;X=0&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;DO WHILE X&amp;lt;50&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;        X=X+1&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;        IF X=20 THEN EXIT DO&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;        PRINT X&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;LOOP&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=270091469191232126&amp;amp;postID=7899159572130974383&quot; name=&quot;tmp&quot;&gt;&lt;b&gt;Program 31 - Exiting Loops in Qbasic&lt;br /&gt;
&lt;/b&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;h3&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=270091469191232126&amp;amp;postID=7899159572130974383&quot; name=&quot;tmp&quot;&gt;For Loops in C/C++&lt;br /&gt;
&lt;/a&gt;&lt;/span&gt;&lt;/h3&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=270091469191232126&amp;amp;postID=7899159572130974383&quot; name=&quot;tmp&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;The for loop in C/C++ is similar to the for loop in Qbasic, except the for loop in C/C++ is more versatile than it is in Qbasic.  In C/C++, the for loop is a counting loop but it can also be used in more advanced topics such as moving between objects [near the end of the book you&#39;ll learn this].&lt;br /&gt;
&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=270091469191232126&amp;amp;postID=7899159572130974383&quot; name=&quot;tmp&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;The for loop in C/C++ has three parameters, the same three that are used in Qbasic, the initiation, count, and incrementer.  All of the parameters in the C/C++ for loop are enclosed in a set of parenthesis ( () ), similar to how an expression is enclosed in parenthesis in the C/C++ if statement.  Besides all the parameters being enclosed in parenthesis, each parameter must be separated by a semicolon (;).&lt;br /&gt;
&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=270091469191232126&amp;amp;postID=7899159572130974383&quot; name=&quot;tmp&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;The first parameter of the for loop is the variable initiation.  This is similar to the variable initiation in the Qbasic for loop.  It is also common to declare the for loop variable within the loop initiation itself, but the variable&#39;s scope is only within that for loop.  &lt;br /&gt;
&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=270091469191232126&amp;amp;postID=7899159572130974383&quot; name=&quot;tmp&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;The second parameter is a logical condition or expression, similar to what would be seen in a while statement.  The for loop will exit when the while statement is false.  In Qbasic, the C/C++ for statement expression would be considered to be a test at top do-while loop.&lt;br /&gt;
&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=270091469191232126&amp;amp;postID=7899159572130974383&quot; name=&quot;tmp&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;The third parameter is the incrementer or decrementor.  This tells the loop how much to increase or decrease the variable by on each time through the loop.  The loop variable should be specified along with how much it should be incremented or decremented by.  For instance, if the loop&#39;s variable is J and to increase it by 1 each time through the loop, use J+1  [a common alternative to using J+1 is to use J++ and use J—for J-1].&lt;br /&gt;
&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=270091469191232126&amp;amp;postID=7899159572130974383&quot; name=&quot;tmp&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Most for statements in C/C++ are usually block for statement, so just as with the if statement, enclose the sequence of statements within braces ( { } ) after the for loop.&lt;br /&gt;
&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=270091469191232126&amp;amp;postID=7899159572130974383&quot; name=&quot;tmp&quot;&gt;The following C++ program shows a for loop that counts from 1 to 5.  As with the if statement, the for loop does not require an include directive.&lt;br /&gt;
&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;table border=&quot;0&quot; style=&quot;border-collapse: collapse;&quot;&gt;&lt;colgroup&gt;&lt;col style=&quot;width: 274px;&quot;&gt;&lt;/col&gt;&lt;/colgroup&gt;&lt;tbody valign=&quot;top&quot;&gt;
&lt;tr&gt;&lt;td style=&quot;border: 0.5pt solid; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;#include &amp;lt;iostream.h&amp;gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;int main()&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;{&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    for(int j=1;j&amp;lt;=5;j++)&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    {&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;        cout&amp;lt;&amp;lt;j&amp;lt;&amp;lt;endl;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    }&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    return 0;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;}&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=270091469191232126&amp;amp;postID=7899159572130974383&quot; name=&quot;tmp&quot;&gt;&lt;b&gt;Program 32 - Simple C/C++ For Loop&lt;br /&gt;
&lt;/b&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=270091469191232126&amp;amp;postID=7899159572130974383&quot; name=&quot;tmp&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;As with most languages, for loops in C/C++ can also be nested.  For loops can be nested just like if statements.  The following program shows a nested for loop that produces a multiplication table from 1 to 5.&lt;br /&gt;
&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;table border=&quot;0&quot; style=&quot;border-collapse: collapse;&quot;&gt;&lt;colgroup&gt;&lt;col style=&quot;width: 312px;&quot;&gt;&lt;/col&gt;&lt;/colgroup&gt;&lt;tbody valign=&quot;top&quot;&gt;
&lt;tr&gt;&lt;td style=&quot;border: 0.5pt solid; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;#include &amp;lt;iostream.h&amp;gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;int main()&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;{&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    for(int j=1;j&amp;lt;=5;j++)&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    {&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;        for(int k=1;k&amp;lt;=5;k++)&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;        {&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;            cout&amp;lt;&amp;lt;j*k&amp;lt;&amp;lt;&quot; &quot;;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;        }&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;        cout&amp;lt;&amp;lt;endl;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    }&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    return 0;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;&lt;i&gt;1 2 3 4 5&lt;br /&gt;
&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;&lt;i&gt;2 4 6 8 10&lt;br /&gt;
&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;&lt;i&gt;3 6 9 12 15&lt;br /&gt;
&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;&lt;i&gt;4 8 12 16 20&lt;br /&gt;
&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;&lt;i&gt;5 10 15 20 25&lt;/i&gt;&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=270091469191232126&amp;amp;postID=7899159572130974383&quot; name=&quot;tmp&quot;&gt;&lt;b&gt;Program 33 - Nested For lops in C/C++&lt;br /&gt;
&lt;/b&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=270091469191232126&amp;amp;postID=7899159572130974383&quot; name=&quot;tmp&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;C/C++ for loops can also be used as timer loops, just like in Qbasic.  In C/C++, the for loop just needs to be followed by a semicolon.  The following example shows a timing delay loop in C/C++.&lt;br /&gt;
&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;table border=&quot;0&quot; style=&quot;border-collapse: collapse;&quot;&gt;&lt;colgroup&gt;&lt;col style=&quot;width: 283px;&quot;&gt;&lt;/col&gt;&lt;/colgroup&gt;&lt;tbody valign=&quot;top&quot;&gt;
&lt;tr&gt;&lt;td style=&quot;border: 0.5pt solid; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;for(int j=0;j&amp;lt;100000;j++);&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=270091469191232126&amp;amp;postID=7899159572130974383&quot; name=&quot;tmp&quot;&gt;&lt;b&gt;Program 34 - C/C++ Time delay for loop&lt;br /&gt;
&lt;/b&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;h3&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=270091469191232126&amp;amp;postID=7899159572130974383&quot; name=&quot;tmp&quot;&gt;Do Loops in C/C++&lt;br /&gt;
&lt;/a&gt;&lt;/span&gt;&lt;/h3&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=270091469191232126&amp;amp;postID=7899159572130974383&quot; name=&quot;tmp&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Unlike Qbasic, C/C++ only has a single version of the do loop and it is similar to Qbasic&#39;s test at bottom do-while loop.  The format of the loop is the word do, followed by a sequence of statements, then the word while followed by the expression enclosed in parenthesis and then finally a semicolon.  The following example illustrates the C/C++ do-while loop.&lt;br /&gt;
&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;table border=&quot;0&quot; style=&quot;border-collapse: collapse;&quot;&gt;&lt;colgroup&gt;&lt;col style=&quot;width: 370px;&quot;&gt;&lt;/col&gt;&lt;/colgroup&gt;&lt;tbody valign=&quot;top&quot;&gt;
&lt;tr&gt;&lt;td style=&quot;border: 0.5pt solid; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;#include &amp;lt;iostream.h&amp;gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;int main()&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;{&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    int a=0;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    do&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    {&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;         cout&amp;lt;&amp;lt;&quot;Enter the number 1&quot;;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;        cin&amp;gt;&amp;gt;a;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    }&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    while (a!=1);&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    return 0;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;}&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=270091469191232126&amp;amp;postID=7899159572130974383&quot; name=&quot;tmp&quot;&gt;&lt;b&gt;Program 35 - C/C++ Do-while Loop&lt;br /&gt;
&lt;/b&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;h3&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=270091469191232126&amp;amp;postID=7899159572130974383&quot; name=&quot;tmp&quot;&gt;While loops in C/C++&lt;br /&gt;
&lt;/a&gt;&lt;/span&gt;&lt;/h3&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=270091469191232126&amp;amp;postID=7899159572130974383&quot; name=&quot;tmp&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;C/C++ offers a loop similar to the while-wend loop in Qbasic.  This loop is simply called the while loop.  This is a test at top loop.  The loop is created by using the while statement followed by an expression within parenthesis, like the do-while loops in C/C++ and then followed by a sequence of statements.  The following program illustrates the while loop.&lt;br /&gt;
&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;table border=&quot;0&quot; style=&quot;border-collapse: collapse;&quot;&gt;&lt;colgroup&gt;&lt;col style=&quot;width: 437px;&quot;&gt;&lt;/col&gt;&lt;/colgroup&gt;&lt;tbody valign=&quot;top&quot;&gt;
&lt;tr&gt;&lt;td style=&quot;border: 0.5pt solid; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;#include &amp;lt;iostream.h&amp;gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;int main()&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;{&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    int a=0;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    cout&amp;lt;&amp;lt;&quot;Enter the number 1&quot;;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    cin&amp;gt;&amp;gt;a;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    while (a!=1);&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    {&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;         cout&amp;lt;&amp;lt;&quot;Please Enter the number 1&quot;;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;        cin&amp;gt;&amp;gt;a;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    }&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    return 0;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=270091469191232126&amp;amp;postID=7899159572130974383&quot; name=&quot;tmp&quot;&gt;&lt;b&gt;Program 36 - C/C++ While loop&lt;br /&gt;
&lt;/b&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;h3&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=270091469191232126&amp;amp;postID=7899159572130974383&quot; name=&quot;tmp&quot;&gt;Infinite Loops in C/C++&lt;br /&gt;
&lt;/a&gt;&lt;/span&gt;&lt;/h3&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=270091469191232126&amp;amp;postID=7899159572130974383&quot; name=&quot;tmp&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Infinite loops are useful in many cases and are sometimes done accidentally.  An infinite loop is a loop that never ends and they can be created using any of the C/C++ loops.&lt;br /&gt;
&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=270091469191232126&amp;amp;postID=7899159572130974383&quot; name=&quot;tmp&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;By using a for loop and setting each of the parameters to nothing [just putting 2 semicolons within the parenthesis], an infinite loop can be created and also an infinite loop can be created by incrementing the variable by nothing.  By using the do-while, or while loops, a infinite loop can be created by making sure the expression is always true.  The following program segments show infinite loops.&lt;br /&gt;
&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;table border=&quot;0&quot; style=&quot;border-collapse: collapse;&quot;&gt;&lt;colgroup&gt;&lt;col style=&quot;width: 226px;&quot;&gt;&lt;/col&gt;&lt;/colgroup&gt;&lt;tbody valign=&quot;top&quot;&gt;
&lt;tr&gt;&lt;td style=&quot;border: 0.5pt solid; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;for(;;)&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;{&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    cout&amp;lt;&amp;lt;&quot;1&quot;;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;}&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;do&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;{&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    cout&amp;lt;&amp;lt;&quot;Here&quot;;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;}&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;while(1);&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;while(1)&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;{&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    cout&amp;lt;&amp;lt;&quot;Goodbye&quot;;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;}&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;for(int j=0;1;)&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;{&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    cout&amp;lt;&amp;lt;&quot;Hello&quot;;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;}&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=270091469191232126&amp;amp;postID=7899159572130974383&quot; name=&quot;tmp&quot;&gt;&lt;b&gt;Program 37 - Infinite Loops in C/C++&lt;br /&gt;
&lt;/b&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;h3&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=270091469191232126&amp;amp;postID=7899159572130974383&quot; name=&quot;tmp&quot;&gt;Ending Loops Prematurely in C/C++&lt;br /&gt;
&lt;/a&gt;&lt;/span&gt;&lt;/h3&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=270091469191232126&amp;amp;postID=7899159572130974383&quot; name=&quot;tmp&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;It is sometimes useful to exit a loop before it ends.  For example, if the programmer designed an infinite loop to retrieve data from the user but the user does not wish to enter any more data, the loop would have to end prematurely.  To end any type of loop in C/C++, the break command should be used.  Program 38 illustrates the use of the break command to prematurely end loops.&lt;br /&gt;
&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;table border=&quot;0&quot; style=&quot;border-collapse: collapse;&quot;&gt;&lt;colgroup&gt;&lt;col style=&quot;width: 283px;&quot;&gt;&lt;/col&gt;&lt;/colgroup&gt;&lt;tbody valign=&quot;top&quot;&gt;
&lt;tr&gt;&lt;td style=&quot;border: 0.5pt solid; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;#include &amp;lt;iostream.h&amp;gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;int main()&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;{&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    for(int j=-5;j&amp;lt;=5;j++)&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    {&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;        if(j==0) break;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;        cout&amp;lt;&amp;lt;20/j&amp;lt;&amp;lt;endl;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    }&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    int x=0;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    while(x&amp;lt;50)&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    {&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;        x=x+1;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;        if (x==20) break;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;        cout&amp;lt;&amp;lt;x&amp;lt;&amp;lt;endl;        &lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    }&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    return 0;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;}&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=270091469191232126&amp;amp;postID=7899159572130974383&quot; name=&quot;tmp&quot;&gt;&lt;b&gt;Program 38 - Exiting Loops in C/C++&lt;br /&gt;
&lt;/b&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;h2&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=270091469191232126&amp;amp;postID=7899159572130974383&quot; name=&quot;tmp&quot;&gt;Conclusion&lt;br /&gt;
&lt;/a&gt;&lt;/span&gt;&lt;/h2&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=270091469191232126&amp;amp;postID=7899159572130974383&quot; name=&quot;tmp&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Decision statements come in two major categories, the branch statement and the loop statement.  &lt;br /&gt;
&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=270091469191232126&amp;amp;postID=7899159572130974383&quot; name=&quot;tmp&quot;&gt;In Qbasic and in C/C++, the branch statement is similar to the English if statement.  The branch statement has an if part that tests whether a condition is true or false, if the condition is true, it does the then part of the statement, if it is false, it does the else part of the statement.  If statements can also be blocked or in other words have multiple commands on the then or the else part of the statement or on both.  If statements can also be compound or nested within each other.  Table 27 shows a comparison of the Qbasic and C/C++ if statements.&lt;br /&gt;
&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;table border=&quot;0&quot; style=&quot;border-collapse: collapse;&quot;&gt;&lt;colgroup&gt;&lt;col style=&quot;width: 63px;&quot;&gt;&lt;/col&gt;&lt;col style=&quot;width: 251px;&quot;&gt;&lt;/col&gt;&lt;col style=&quot;width: 181px;&quot;&gt;&lt;/col&gt;&lt;/colgroup&gt;&lt;tbody valign=&quot;top&quot;&gt;
&lt;tr&gt;&lt;td style=&quot;border: 0.5pt solid; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;b&gt;Type&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: solid solid solid none; border-width: 0.5pt 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;b&gt;Qbasic&lt;/b&gt;&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: solid solid solid none; border-width: 0.5pt 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;b&gt;C/C++&lt;/b&gt;&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;Simple&lt;/span&gt;&amp;nbsp;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;IF a=1 THEN PRINT a&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;if (a==1) cout&amp;lt;&amp;lt;a;&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;Simple&lt;/span&gt;&amp;nbsp;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;IF a=2 THEN PRINT a+2 ELSE PRINT b&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;if (a==2) cout&amp;lt;&amp;lt;a+2;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;else cout&amp;lt;&amp;lt;b;&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;Block&lt;/span&gt;&amp;nbsp;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;IF b=5 THEN &lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;        PRINT c&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;        b=c &lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;ELSE &lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;        PRINT b&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;END IF&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;if (b==5)&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;{&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;    cout&amp;lt;&amp;lt;c;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;    b=c;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;}&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;else&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;    cout&amp;lt;&amp;lt;b;&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;Block&lt;/span&gt;&amp;nbsp;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;IF b=5 THEN &lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;        PRINT c &lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;ELSE &lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;        PRINT b&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;        c=b&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;END IF&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;if (b==5)&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;    cout&amp;lt;&amp;lt;c;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;else&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;{&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;    cout&amp;lt;&amp;lt;b;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;    c=b;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;}&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;Block&lt;/span&gt;&amp;nbsp;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;IF b=5 THEN &lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;        PRINT c&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;        b=c &lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;ELSE &lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;        PRINT b&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;        c=b&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;END IF&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;if (b==5)&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;{&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;    cout&amp;lt;&amp;lt;c;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;    b=c;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;}&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;else&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;{&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;    cout&amp;lt;&amp;lt;b;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;    c=b;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;}&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;Nested&lt;/span&gt;&amp;nbsp;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;IF b=5 THEN &lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;        IF c=1 THEN&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;                PRINT B&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;                PRINT c&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;        ELSE&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;                b=c&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;        END IF&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;ELSE &lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;        PRINT b&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;        c=b&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;END IF&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;if (b==5)&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;{&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;    if (c==1)&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;    {&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;        cout&amp;lt;&amp;lt;c;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;        cout&amp;lt;&amp;lt;b;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;    }&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;    else&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;        b=c;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;}&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;else&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;{&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;    cout&amp;lt;&amp;lt;b;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;    c=b;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;Simple&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;w/ else if&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;IF b=2 THEN PRINT c&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;ELSEIF c=2 THEN PRINT B&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;if (b==2) cout&amp;lt;&amp;lt;c;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;else if (c==2) cout&amp;lt;&amp;lt;b;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=270091469191232126&amp;amp;postID=7899159572130974383&quot; name=&quot;tmp&quot;&gt;&lt;b&gt;Table 27 - Qbasic and C/C++ If Statements&lt;br /&gt;
&lt;/b&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=270091469191232126&amp;amp;postID=7899159572130974383&quot; name=&quot;tmp&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Loops are useful for doing repetitive tasks such as counting or doing a series of steps until something happens.  There are three main types of loops in Qbasic and in C/C++, the for loop, the do loop, and the while loop.  In Qbasic, the do loop has the option of being a test at top or test at bottom loop, whereas in C/C++, the do loop is only a test at bottom loop.  The while loop in both languages is a test at top loop.  The three loops are shown in Table 28 in both of the languages.  &lt;br /&gt;
&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=270091469191232126&amp;amp;postID=7899159572130974383&quot; name=&quot;tmp&quot;&gt;Both languages allow for breaking out of a loop before the loop condition becomes false.  In Qbasic, the exit command will exit out of a loop and in C/C++, the break command will exit out of a loop.  These are also illustrated in Table 28.&lt;br /&gt;
&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=270091469191232126&amp;amp;postID=7899159572130974383&quot; name=&quot;tmp&quot;&gt;Loop can also be designed to never end or be infinite.  Infinite loops are useful in games or in cases where an unknown amount of information will be retrieved.  Table 28 also describes infinite loops.&lt;br /&gt;
&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;table border=&quot;0&quot; style=&quot;border-collapse: collapse;&quot;&gt;&lt;colgroup&gt;&lt;col style=&quot;width: 107px;&quot;&gt;&lt;/col&gt;&lt;col style=&quot;width: 232px;&quot;&gt;&lt;/col&gt;&lt;col style=&quot;width: 251px;&quot;&gt;&lt;/col&gt;&lt;/colgroup&gt;&lt;tbody valign=&quot;top&quot;&gt;
&lt;tr&gt;&lt;td style=&quot;border: 0.5pt solid; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 8pt;&quot;&gt;&lt;b&gt;Type&lt;/b&gt;&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: solid solid solid none; border-width: 0.5pt 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 8pt;&quot;&gt;&lt;b&gt;Qbasic&lt;/b&gt;&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: solid solid solid none; border-width: 0.5pt 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 8pt;&quot;&gt;&lt;b&gt;C/C++&lt;/b&gt;&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 8pt;&quot;&gt;For loop&lt;/span&gt;&amp;nbsp;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;FOR J=1 TO 10&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;        PRINT J&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;NEXT J&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;for(int j=1;j&amp;lt;=10;j++)&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;{&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;    cout&amp;lt;&amp;lt;j&amp;lt;&amp;lt;endl;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;}&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 8pt;&quot;&gt;For loop&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 8pt;&quot;&gt;with &lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 8pt;&quot;&gt;non-default&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 8pt;&quot;&gt; increment &lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 8pt;&quot;&gt;and premature&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 8pt;&quot;&gt; exit&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;FOR J=-5 TO 5 STEP .5&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;        IF J=0 THEN EXIT FOR&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;        PRINT 20/J&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;NEXT J&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;for(float j=-5;j&amp;lt;=5;j+.5)&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;{&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;    if(j==0) break;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;    cout&amp;lt;&amp;lt;20/j&amp;lt;&amp;lt;endl;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;}&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 8pt;&quot;&gt;For loop with &lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 8pt;&quot;&gt;decrement&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;FOR J=10 TO 1 STEP -1&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;        PRINT J&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;NEXT J&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;for(int j=10;j&amp;gt;=1;j--)&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;{&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;    cout&amp;lt;&amp;lt;j&amp;lt;&amp;lt;endl;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;}&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 8pt;&quot;&gt;Infinite For loop&lt;/span&gt;&amp;nbsp;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;FOR J=1 TO 10 STEP 0&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;        PRINT J&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;NEXT J&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;for(int j=1;j&amp;lt;=10;j+0)&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;{&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;    cout&amp;lt;&amp;lt;j&amp;lt;&amp;lt;endl;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;}&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 8pt;&quot;&gt;Infinite For loop&lt;/span&gt;&amp;nbsp;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;n/a&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;for(;;)&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;{&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;    cout&amp;lt;&amp;lt;&quot;Hello&quot;&amp;lt;&amp;lt;endl;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;}&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 8pt;&quot;&gt;Infinite For loop&lt;/span&gt;&amp;nbsp;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;n/a&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;for (int j=1;;)&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;{&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;    cout&amp;lt;&amp;lt;&quot;Hello&quot;&amp;lt;&amp;lt;endl;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;}&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 8pt;&quot;&gt;Infinite For loop&lt;/span&gt;&amp;nbsp;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;n/a&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;for (;1;)&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;{&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;    cout&amp;lt;&amp;lt;&quot;Hello&quot;&amp;lt;&amp;lt;endl;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;}&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 8pt;&quot;&gt;Test at Top While&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;DO WHILE a&amp;lt;&amp;gt;1&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;        PRINT &quot;Incorrect Value&quot;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;        PRINT &quot;Please Press 1&quot;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;        INPUT A&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;LOOP&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;int a=0;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;while (a!=1)&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;{&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;    cout&amp;lt;&amp;lt;&quot;Incorrect Value&quot;&amp;lt;&amp;lt;endl;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;    cout&amp;lt;&amp;lt;&quot;Please press 1&quot;;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;    cin&amp;gt;&amp;gt;a;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;}&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 8pt;&quot;&gt;Test at Bottom While&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;DO&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;       PRINT &quot;Enter number 1&quot;;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;       INPUT A&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;LOOP WHILE A&amp;lt;&amp;gt;1&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;int a=0;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;do&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;{&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;    cout&amp;lt;&amp;lt;&quot;Enter number 1&quot;;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;    cin&amp;gt;&amp;gt;a;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;}while(a!=1);&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 8pt;&quot;&gt;Test at Top Until&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;DO UNTIL a=2&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;       PRINT &quot;Incorrect Value&quot;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;       PRINT &quot;Please Press 2&quot;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;       INPUT A&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;LOOP&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;int a=0;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;while (a!=2)&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;{&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;    cout&amp;lt;&amp;lt;&quot;Incorrect Value&quot;&amp;lt;&amp;lt;endl;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;    cout&amp;lt;&amp;lt;&quot;Please Press 2&quot;;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;    cin&amp;gt;&amp;gt;a;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;}&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 8pt;&quot;&gt;Test at Bottom Until&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;DO&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;        PRINT &quot;Enter 1&quot;;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;        INPUT A&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;LOOP UNTIL A=1&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;int a=0;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;do&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;{&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;    cout&amp;lt;&amp;lt;&quot;Enter 1&quot;;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;    cin&amp;gt;&amp;gt;a;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;}while(a!=2);&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 8pt;&quot;&gt;While Loop&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;WHILE a&amp;lt;&amp;gt;2&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;       PRINT &quot;Incorrect Value&quot;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;       PRINT &quot;Please Press 2&quot;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;        INPUT A&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;WEND&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;while (a!=2)&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;{&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;    cout&amp;lt;&amp;lt;&quot;Incorrect Value&quot;&amp;lt;&amp;lt;endl;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;    cout&amp;lt;&amp;lt;&quot;Please Press 2&quot;;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;    cin&amp;gt;&amp;gt;a;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;}&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 8pt;&quot;&gt;Infinite While Loop&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;DO&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;LOOP WHILE 1&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;do&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;{&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;}while(1);&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 8pt;&quot;&gt;Infinite Until Loop&lt;/span&gt;&amp;nbsp;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;DO&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;LOOP UNTIL A&amp;lt;&amp;gt;A&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;do&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;{&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;}while(a==a);&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 8pt;&quot;&gt;While Premature exit&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;n/a&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;int a=0;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;while(1)&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;{&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;    a++;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;    if(a&amp;gt;=50) break;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;    cout&amp;lt;&amp;lt;a;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;}&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 8pt;&quot;&gt;Do Premature exit&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;DO&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;        X=X+1&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;        IF X=20 THEN EXIT DO&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;        PRINT X&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;LOOP WHILE x&amp;lt;50&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;int x=0;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;do&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;{&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;    x=x+1;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;    if(x==20) break;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;    cout&amp;lt;&amp;lt;x;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;}while(x&amp;lt;50);&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=270091469191232126&amp;amp;postID=7899159572130974383&quot; name=&quot;tmp&quot;&gt;&lt;b&gt;Table 28 - Qbasic and C/C++ Loop Statements&lt;br /&gt;
&lt;/b&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;h2&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=270091469191232126&amp;amp;postID=7899159572130974383&quot; name=&quot;tmp&quot;&gt;Problems&lt;br /&gt;
&lt;/a&gt;&lt;/span&gt;&lt;/h2&gt;&lt;ol&gt;&lt;span xmlns=&quot;&quot;&gt;
&lt;li&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=270091469191232126&amp;amp;postID=7899159572130974383&quot; name=&quot;tmp&quot;&gt;Write a program to calculate the sum, difference, product, quotient, and remainder of two numbers from the user.  Be sure the user knows exactly what to input (i.e. use a prompt).  Continue doing this program until the user enters -1 and -1 for the input.&lt;br /&gt;
&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=270091469191232126&amp;amp;postID=7899159572130974383&quot; name=&quot;tmp&quot;&gt;Modify Problem 1 to calculate the logical and and logical or of two numbers given by the user.  Be sure to use a prompt.  Force the user to enter only binary values of 0 or 1.  If the user wishes to exit, allow -1, -1 to exit the program.&lt;br /&gt;
&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=270091469191232126&amp;amp;postID=7899159572130974383&quot; name=&quot;tmp&quot;&gt;Write a program that counts from 1 to 50 and then from 50 to 1.  Print out each line of output on a line by itself.&lt;br /&gt;
&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;
&lt;/span&gt;&lt;/ol&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;/span&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://rhale78.blogspot.com/feeds/7899159572130974383/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://rhale78.blogspot.com/2010/02/intro-to-computer-programming-chapter-7.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/270091469191232126/posts/default/7899159572130974383'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/270091469191232126/posts/default/7899159572130974383'/><link rel='alternate' type='text/html' href='http://rhale78.blogspot.com/2010/02/intro-to-computer-programming-chapter-7.html' title='Intro to Computer Programming - Chapter 7: Making Decisions'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/09185478558704427023</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-270091469191232126.post-5414220450736237491</id><published>2010-02-26T17:53:00.001-05:00</published><updated>2010-02-26T17:53:00.178-05:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Intro to Computer Programming"/><title type='text'>Intro to Computer Programming - Chapter 6: Communicating with the Computer</title><content type='html'>&lt;span xmlns=&quot;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;h2&gt;&lt;span xmlns=&quot;&quot;&gt;Introduction&lt;br /&gt;
&lt;/span&gt;&lt;/h2&gt;&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;As stated in Chapter 4, one of the most common things a computer can do is print information to the screen.  The next most common thing a computer does is ask the user for input.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Input has many places it could come from.  It could come from the keyboard, the mouse, the sound card, a touch screen, modem, a file, among many others.  The most common of these is the keyboard.  This chapter will deal with keyboard based input from the user.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;h2&gt;&lt;span xmlns=&quot;&quot;&gt;Keyboard input with Qbasic&lt;br /&gt;
&lt;/span&gt;&lt;/h2&gt;&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Qbasic has several keyboard input statements.  The two most common for most programs is the input statement and the line input statement.  Both of these commands wait for the user to press the enter key before it accepts any information from the user.  After the user presses enter, the information is then transferred into a variable for later processing.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;h3&gt;&lt;span xmlns=&quot;&quot;&gt;Input Statement&lt;br /&gt;
&lt;/span&gt;&lt;/h3&gt;&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;The input statement is one of Qbasic&#39;s most versatile of keyboard input commands.  It allows the programmer to request multiple pieces of information from a user and automatically checks to see that the entered data was valid.  The input statement also allows the programmer to include a prompt along with the request for information.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;The input statement allows the programmer to use multiple variables by using the same input statement.  For example, if the programmer wanted an integer, a string, and a float entered, one input statement could be used.  The way the statement is formed is by putting the statement input followed by a list of variables, each separated by a comma (,), that will hold what the user typed in.  After the enter key is pressed, Qbasic automatically verifies the information to make sure the user actually typed a number when a number was requested instead of a string.  If the user accidentally put the wrong type of information for an input, Qbasic will ask the user to redo the input by printing the words &quot;Redo from Start&quot; on the screen and it will ask again for the input from the user.  It will continue to do this until the user inputs the correct information.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;The input statement has several options that can be included.  These include a prompt, keeping on the same line, and inserting a question mark after the prompt.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;The first option that can be used is the use of a prompt.  A prompt can be included in the input statement so that the user will know what information is requested by the program.  The prompt is simply enclosed in quotes after the input statement, just as is done with the print statement.  Notice that the prompt can not be any type of expression but must be a string.  The prompt must also come before the input variable list.  You may ask why isn&#39;t the prompt just printed using a print statement, the answer is because if the user enters the incorrect information, the prompt will not be displayed again unless it is part of the input statement.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;The second option is the ability to continue on the same line.  This is similar to the way the print statement can stay on the same line after it displays its output.  The option is also similar to the print statement in that a semicolon (;) is used.  With the print statement, the semicolon is used after the output, but in the case of the input statement, the semicolon must be directly after the input command and before the prompt, if there is one.  &lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;The third option is the ability to automatically include a question mark (?) after the prompt.  This option is automatically performed if a prompt is not included in the statement.  The way to prevent a question mark from appearing as part of the prompt is to place a comma between the prompt and the input variable list.  If a question mark is requested, the programmer should place a semicolon between the prompt and the input variable list.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;The user of a program that uses the input statement should know that numbers should not contain commas because the comma is considered to be a delimiter.  A delimiter is any character or set of characters that marks the end of a word, number, or phrase (for example, the delimiters for words are spaces, and most punctuation symbols excluding the apostrophe (&#39;)).  With the input statement, commas are always considered to be a delimiter for both numbers and for strings (with the input statement, a string can not contain a comma unless the string is enclosed in quotes).  So, for example, if the user enters the numbers 45,167 the computer would accept the 45 as the first input and the 167 as the second.  If the computer was expecting only one number, it would request the user to enter the information again which could possibly frustrate the user.  &lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;Also, when the program is expecting a number, symbols other than numbers, negative or positive signs, or the decimal point are illegal.  For instance if the program is asking for how much the user makes per hour and the user enters $4.75, the program would reject the input because the dollar sign is an illegal symbol for a number.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;The following program and dialog between the computer and user demonstrate the uses of the input statement.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;table border=&quot;0&quot; style=&quot;border-collapse: collapse;&quot;&gt;&lt;colgroup&gt;&lt;col style=&quot;width: 555px;&quot;&gt;&lt;/col&gt;&lt;/colgroup&gt;&lt;tbody valign=&quot;top&quot;&gt;
&lt;tr&gt;&lt;td style=&quot;border: 0.5pt solid; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 10pt;&quot;&gt;INPUT &quot;What is your name&quot;;A$&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 10pt;&quot;&gt;PRINT &quot;Hello, &quot;;A$;&quot;.&quot;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 10pt;&quot;&gt;INPUT &quot;Enter 2 numbers separated by commas:&quot;,A,B&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 10pt;&quot;&gt;PRINT A$;&quot;, &quot;;&quot;the sum of&quot;;A;&quot; and&quot;;B;&quot; is&quot;;A+B&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 10pt;&quot;&gt;PRINT &quot;I would like to calculate about how much your&quot;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 10pt;&quot;&gt;PRINT &quot;next paycheck will be.&quot;  &lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 10pt;&quot;&gt;PRINT &quot;How many hours did you work the past 2 weeks?&quot;;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 10pt;&quot;&gt;INPUT ;&quot;&quot;,hours&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 10pt;&quot;&gt;PRINT &quot; at how much per hour&quot;;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 10pt;&quot;&gt;INPUT wage&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 10pt;&quot;&gt;PRINT A$; &quot;,&quot;;&quot;you will be getting paid approximately&quot;;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 10pt;&quot;&gt;PRINT &quot;$&quot;;hours*wage&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New;&quot;&gt;&lt;i&gt;What is your name?&lt;/i&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Times New Roman;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;font-family: Courier New;&quot;&gt;&lt;b&gt;Joe&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Times New Roman;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 9pt;&quot;&gt;&lt;i&gt;Hello, Joe.&lt;br /&gt;
&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 9pt;&quot;&gt;&lt;i&gt;Enter 2 numbers separated by commas: &lt;b&gt;4, 8&lt;/b&gt;&lt;br /&gt;
&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 9pt;&quot;&gt;&lt;i&gt;Joe, the sum of 4 and 8 is 12&lt;br /&gt;
&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 9pt;&quot;&gt;&lt;i&gt;I would like to calculate about how much your&lt;br /&gt;
&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 9pt;&quot;&gt;&lt;i&gt;next paycheck will be.&lt;br /&gt;
&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 9pt;&quot;&gt;&lt;i&gt;How many hours did you work the past 2 weeks? &lt;/i&gt;&lt;b&gt;40&lt;/b&gt;&lt;i&gt; at how much per hour? &lt;/i&gt;&lt;b&gt;5.75&lt;/b&gt;&lt;i&gt;&lt;br /&gt;
&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 9pt;&quot;&gt;&lt;i&gt;Joe, you will be getting paid approximately $ 230&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New;&quot;&gt;&lt;i&gt;What is your name?&lt;/i&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Times New Roman;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;font-family: Courier New;&quot;&gt;&lt;b&gt;Doe, John&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Times New Roman;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 9pt;&quot;&gt;&lt;i&gt;Redo from start&lt;br /&gt;
&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New;&quot;&gt;&lt;i&gt;What is your name?&lt;/i&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Times New Roman;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;font-family: Courier New;&quot;&gt;&lt;b&gt;John Doe&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Times New Roman;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 9pt;&quot;&gt;&lt;i&gt;Hello, John Doe.&lt;br /&gt;
&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 9pt;&quot;&gt;&lt;i&gt;Enter 2 numbers separated by commas: &lt;b&gt;4, 8, 7&lt;br /&gt;
&lt;/b&gt;&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 9pt;&quot;&gt;&lt;i&gt;Redo from start&lt;br /&gt;
&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 9pt;&quot;&gt;&lt;i&gt;Enter 2 numbers separated by commas: &lt;b&gt;7, 5&lt;br /&gt;
&lt;/b&gt;&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 9pt;&quot;&gt;&lt;i&gt;John Doe, the sum of 7 and 5 is 13&lt;br /&gt;
&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 9pt;&quot;&gt;&lt;i&gt;I would like to calculate about how much your&lt;br /&gt;
&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 9pt;&quot;&gt;&lt;i&gt;next paycheck will be.&lt;br /&gt;
&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 9pt;&quot;&gt;&lt;i&gt;How many hours did you work the past 2 weeks? &lt;/i&gt;&lt;b&gt;4&lt;/b&gt;&lt;i&gt; at how much per hour? &lt;/i&gt;&lt;b&gt;$6.00&lt;/b&gt;&lt;i&gt;&lt;br /&gt;
&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 9pt;&quot;&gt;&lt;i&gt;Redo from start&lt;br /&gt;
&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 9pt;&quot;&gt;&lt;i&gt; at how much per hour? &lt;/i&gt;&lt;b&gt;6.00&lt;/b&gt;&lt;i&gt;&lt;br /&gt;
&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 9pt;&quot;&gt;&lt;i&gt;John Doe, you will be getting paid approximately $ 24&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;b&gt;Program 16 – Qbasic Input Demonstration&lt;br /&gt;
&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;h3&gt;&lt;span xmlns=&quot;&quot;&gt;Line Input Statement&lt;br /&gt;
&lt;/span&gt;&lt;/h3&gt;&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;In comparison to the input statement, the line input statement is very limited in its uses.  This limitation has its advantages though.  The line input statement has no options and also is only able to input strings.  The advantage to this is that line input does not respond to any delimiters with the exception of the enter key so any character is allowed to be entered and the program will not come back and say &quot;Redo from Start&quot;.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Program 17 demonstrates the use of the line input statement.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;table border=&quot;0&quot; style=&quot;border-collapse: collapse;&quot;&gt;&lt;colgroup&gt;&lt;col style=&quot;width: 274px;&quot;&gt;&lt;/col&gt;&lt;/colgroup&gt;&lt;tbody valign=&quot;top&quot;&gt;
&lt;tr&gt;&lt;td style=&quot;border: 0.5pt solid; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;LINE INPUT A$&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;PRINT&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;PRINT A$&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;&lt;b&gt;&quot;Hello, how are you doing?&quot;&lt;br /&gt;
&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;&lt;i&gt;&quot;Hello, how are you doing?&quot;&lt;/i&gt;&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;b&gt;Program 17 - Qbasic Line Input Program&lt;br /&gt;
&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;h2&gt;&lt;span xmlns=&quot;&quot;&gt;Keyboard input with C&lt;br /&gt;
&lt;/span&gt;&lt;/h2&gt;&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Once again, the complexity of C raises its ugly head with keyboard input as it did with the printf command, which hasn&#39;t yet been completely covered.  The keyboard input command for C is just as complex as its output function printf.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;The scanf function is C&#39;s version of keyboard input.  It is very similar in style to the printf function.  With the scanf function, the type of the variables to be inputted must be specified by using a type specifier.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Because the scanf function is only input, it cannot display any information on the screen, but the command format is similar to the printf function in that the type specifiers are enclosed in quotes, and after the quotes are a list of the input variables.  One difference between the printf function and scanf functions is that the input variables of the scanf function must be preceded by an ampersand (&amp;amp;) [at least at this point in the book].  The reason for the ampersand will be explained in a later chapter.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;The type specifiers of the scanf (and printf) functions are preceeded by a percent sign (%) and then the specifier itself.  The following table lists the type specifiers for the scanf and printf functions (notice that the percent sign is already included).  One difference between the printf and scanf type specifiers is that the scanf type specifiers should be preceeded by a space.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;table border=&quot;0&quot; style=&quot;border-collapse: collapse;&quot;&gt;&lt;colgroup&gt;&lt;col style=&quot;width: 97px;&quot;&gt;&lt;/col&gt;&lt;col style=&quot;width: 134px;&quot;&gt;&lt;/col&gt;&lt;/colgroup&gt;&lt;tbody valign=&quot;top&quot;&gt;
&lt;tr&gt;&lt;td style=&quot;border: 0.5pt solid; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;b&gt;Type Specifier&lt;/b&gt;&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: solid solid solid none; border-width: 0.5pt 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;b&gt;Description&lt;/b&gt;&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;%d&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;Integer&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;%f&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;Floating point number&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;%e&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;Floating point in &lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;scientific notation&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;(for printf)&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;%g&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;Shortest of either &lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;floating point or &lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;scientific notation&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;(for printf)&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;%c&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;Character&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;%s&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;String [don&#39;t use yet!]&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;b&gt;Table 24 – Scanf and printf type specifiers&lt;br /&gt;
&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;br /&gt;
&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;As with most of C/C++&#39;s functions, an include file must be specified in order to allow the program to use scanf.  The include file for scanf is the same as it is for the printf function, stdio.h.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;The scanf function is unlike the Qbasic input command in that it does not do any checking of what the user typed in as input nor does it automatically create a prompt for the user.  Both of these tasks must be accomplished by the programmer.  The scanf function [with the information you know so far] can also only input a single character, unlike the input or line input commands of Qbasic which can input words or entire lines of characters.  The scanf function is similat to input in that the user must press enter or return before the computer will accept the input.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;The following program demonstrates the use of the scanf and printf statements.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;table border=&quot;0&quot; style=&quot;border-collapse: collapse;&quot;&gt;&lt;colgroup&gt;&lt;col style=&quot;width: 570px;&quot;&gt;&lt;/col&gt;&lt;/colgroup&gt;&lt;tbody valign=&quot;top&quot;&gt;
&lt;tr&gt;&lt;td style=&quot;border: 0.5pt solid; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 10pt;&quot;&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 10pt;&quot;&gt;int main()&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 10pt;&quot;&gt;{&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 10pt;&quot;&gt;    int j;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 10pt;&quot;&gt;    char t;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 10pt;&quot;&gt;    float y;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 10pt;&quot;&gt;    int a1,b1;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 10pt;&quot;&gt;    printf(&quot;Please enter an integer:&quot;);&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 10pt;&quot;&gt;    scanf(&quot; %d&quot;,&amp;amp;j);&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 10pt;&quot;&gt;    printf(&quot;Please enter a non-integer number:&quot;);&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 10pt;&quot;&gt;    scanf(&quot; %f&quot;,&amp;amp;y);&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 10pt;&quot;&gt;    printf(&quot;Please enter a character:&quot;);&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 10pt;&quot;&gt;    scanf(&quot; %c&quot;,&amp;amp;t);&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 10pt;&quot;&gt;    printf(&quot;You entered the integer number %d\n&quot;,j);&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 10pt;&quot;&gt;    printf(&quot;                     the non-integer number %g\n&quot;,y);&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 10pt;&quot;&gt;    printf(&quot;                     the character %c\n&quot;,t);&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 10pt;&quot;&gt;    printf(&quot;\n&quot;);&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 10pt;&quot;&gt;    printf(&quot;Please enter 2 integer numbers separated by a space:&quot;);&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 10pt;&quot;&gt;    scanf(&quot; %d %d&quot;,&amp;amp;a1,&amp;amp;b1);&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 10pt;&quot;&gt;    printf(&quot;The sum of %d and %d is %d\n&quot;,a1,b1,a1+b1);&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 10pt;&quot;&gt;    return 0;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New;&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New;&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;&lt;i&gt;Please enter an integer:&lt;/i&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;&lt;b&gt;4&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;&lt;i&gt;&lt;br /&gt;
&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New;&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;&lt;i&gt;Please enter a non-integer number:&lt;/i&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;&lt;b&gt;1.5&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;&lt;i&gt;&lt;br /&gt;
&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New;&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;&lt;i&gt;Please enter a character:&lt;/i&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;&lt;b&gt;x&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;&lt;i&gt;&lt;br /&gt;
&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 10pt;&quot;&gt;&lt;i&gt;You entered the integer number 4&lt;br /&gt;
&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 10pt;&quot;&gt;&lt;i&gt;                     the non-integer number 1.5&lt;br /&gt;
&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 10pt;&quot;&gt;&lt;i&gt;                     the character x&lt;br /&gt;
&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New;&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;&lt;i&gt;Please enter 2 integer numbers separated by a space:&lt;/i&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;&lt;b&gt;1 4&lt;br /&gt;
&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 10pt;&quot;&gt;&lt;i&gt;The sum of 1 and 4 is 5&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;b&gt;Program 18 - Scanf and printf example program&lt;br /&gt;
&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Notice how the type specifiers can be &quot;chained&quot; together in both the printf and scanf statements.  In the printf function, the type specifiers do not require a space between them but the scanf function requires a space [technically the space is not required but is recommended to prevent input problems].&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Just as wish Qbasic, the scanf statement includes automatic delimiters of space, comma, and enter.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;It is the programmer&#39;s responsibility to check the input that the user typed to make sure that it is valid.  For example, the user could type in a decimal point (.) instead of a number and scanf will continue without warning, or the user could&#39;ve entered a floating point number instead of an integer.  The programmer needs to be aware that scanf does not check the data that has been entered.  The next chapter will explain some ways of how to check for valid data.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;h2&gt;&lt;span xmlns=&quot;&quot;&gt;Keyboard input with C++&lt;br /&gt;
&lt;/span&gt;&lt;/h2&gt;&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Once again, C++ is a mixture of the advantages of C and Qbasic combined.  The cin statement in C++ is similar to the printf statement in C in that a prompt is not outputted automatically and that the data is not checked for the correct type.  The cin statement has the advantage of being simplier than the C printf function in that the type specifiers are not used and the cin statement&#39;s structure is similar to that of the print statement in Qbasic.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;In an earlier chapter, you learned that the cout statement uses the double-less-than operator (&amp;lt;&amp;lt;) between the cout statement and the requested output.  The cin statement is similar in that it uses the opposite operator, the double-greater-than (&amp;gt;&amp;gt;) between the cin statement and the variables used for input.  As with the cout statement, the operators can be chained together.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;The cin statement falls under the same category as the cout statement and therefore requires the same include file, iostream.h, to be included in the program.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Just as with the input statement and scanf function, the cin statement includes delimeters of space, comma, and enter.  Also, just as the scanf statement, the input is not checked for correctness nor correct type therefore the programmer must ensure the user entered the correct data.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;The following program illustrates the general use of the cin statement.  At this time, as with scanf, strings are not able to be used by cin.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;table border=&quot;0&quot; style=&quot;border-collapse: collapse;&quot;&gt;&lt;colgroup&gt;&lt;col style=&quot;width: 562px;&quot;&gt;&lt;/col&gt;&lt;/colgroup&gt;&lt;tbody valign=&quot;top&quot;&gt;
&lt;tr&gt;&lt;td style=&quot;border: 0.5pt solid; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 10pt;&quot;&gt;#include &amp;lt;iostream.h&amp;gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 10pt;&quot;&gt;int main()&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 10pt;&quot;&gt;{&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 10pt;&quot;&gt;    int j;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 10pt;&quot;&gt;    char t;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 10pt;&quot;&gt;    float y;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 10pt;&quot;&gt;    int a1,b1;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 10pt;&quot;&gt;    cout&amp;lt;&amp;lt;&quot;Please enter an integer:&quot;;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 10pt;&quot;&gt;    cin&amp;gt;&amp;gt;j;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 10pt;&quot;&gt;    cout&amp;lt;&amp;lt;&quot;Please enter a non-integer number:&quot;;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 10pt;&quot;&gt;    cin&amp;gt;&amp;gt;y;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 10pt;&quot;&gt;    cout&amp;lt;&amp;lt;&quot;Please enter a character:&quot;;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 10pt;&quot;&gt;    cin&amp;gt;&amp;gt;t;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 10pt;&quot;&gt;    cout&amp;lt;&amp;lt;&quot;You entered the integer number &quot;&amp;lt;&amp;lt;j&amp;lt;&amp;lt;endl;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 10pt;&quot;&gt;    cout&amp;lt;&amp;lt;&quot;                     the non-integer number &quot;&amp;lt;&amp;lt;y&amp;lt;&amp;lt;endl;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 10pt;&quot;&gt;    cout&amp;lt;&amp;lt;&quot;                     the character &quot;&amp;lt;&amp;lt;t&amp;lt;&amp;lt;endl;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 10pt;&quot;&gt;    cout&amp;lt;&amp;lt;endl;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 10pt;&quot;&gt;    cout&amp;lt;&amp;lt;&quot;Please enter 2 integer numbers separated by a space:&quot;;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 10pt;&quot;&gt;    cin&amp;gt;&amp;gt;a1&amp;gt;&amp;gt;b1;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 10pt;&quot;&gt;    cout&amp;lt;&amp;lt;&quot;The sum of &quot;&amp;lt;&amp;lt;a1&amp;lt;&amp;lt;&quot; and &quot;&amp;lt;&amp;lt;b1&amp;lt;&amp;lt;&quot; is &quot;&amp;lt;&amp;lt;a1+b1&amp;lt;&amp;lt;endl;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 10pt;&quot;&gt;    return 0;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New;&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New;&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;&lt;i&gt;Please enter an integer:&lt;/i&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;&lt;b&gt;4&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;&lt;i&gt;&lt;br /&gt;
&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New;&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;&lt;i&gt;Please enter a non-integer number:&lt;/i&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;&lt;b&gt;1.5&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;&lt;i&gt;&lt;br /&gt;
&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New;&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;&lt;i&gt;Please enter a character:&lt;/i&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;&lt;b&gt;x&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;&lt;i&gt;&lt;br /&gt;
&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 10pt;&quot;&gt;&lt;i&gt;You entered the integer number 4&lt;br /&gt;
&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 10pt;&quot;&gt;&lt;i&gt;                     the non-integer number 1.5&lt;br /&gt;
&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 10pt;&quot;&gt;&lt;i&gt;                     the character x&lt;br /&gt;
&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New;&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;&lt;i&gt;Please enter 2 integer numbers separated by a space:&lt;/i&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;&lt;b&gt;1 4&lt;br /&gt;
&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 10pt;&quot;&gt;&lt;i&gt;The sum of 1 and 4 is 5&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;br /&gt;
&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;h2&gt;&lt;span xmlns=&quot;&quot;&gt;Conclusion&lt;br /&gt;
&lt;/span&gt;&lt;/h2&gt;&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Each language has some sort of command to get input from the user, the most common type of input being input from the keyboard.  The commands seen so far have required the user pressing the enter key in order to tell the computer the user was finished entering data.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;The input command in Qbasic is very versatile in that it allows for automatic prompting of the user as well as inputting various types of data such as integers and strings.  It also does a check to verify that all data is at least the correct type.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;The line input statement in Qbasic is useful for inputting strings that could contain commas or other types of punctuation that could be considered a delimiter when used with the input command.  It does not allow automatic prompting.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;The scanf function in C is similar to the printf function in its command structure.  A quoted string of type specifiers (shown in table 24) describes the input and a list of variables follows the string.  The scanf function does not check the user inputted data against the type specifiers nor does it allow for automatic prompting.  The scanf statement also requires an ampersand before the names of the variables and a space should separate the type specifiers within the input string.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;table border=&quot;0&quot; style=&quot;border-collapse: collapse;&quot;&gt;&lt;colgroup&gt;&lt;col style=&quot;width: 97px;&quot;&gt;&lt;/col&gt;&lt;col style=&quot;width: 134px;&quot;&gt;&lt;/col&gt;&lt;/colgroup&gt;&lt;tbody valign=&quot;top&quot;&gt;
&lt;tr&gt;&lt;td style=&quot;border: 0.5pt solid; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;b&gt;Type Specifier&lt;/b&gt;&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: solid solid solid none; border-width: 0.5pt 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;b&gt;Description&lt;/b&gt;&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;%d&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;Integer&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;%f&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;Floating point number&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;%e&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;Floating point in &lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;scientific notation&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;(for printf)&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;%g&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;Shortest of either &lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;floating point or &lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;scientific notation&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;(for printf)&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;%c&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;Character&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;%s&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;String [don&#39;t use yet!]&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;b&gt;Table 25 – Scanf and printf type specifiers&lt;br /&gt;
&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;br /&gt;
&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;The cin statement is similar to the cout statement except it uses the double-greater-than operator (&amp;gt;&amp;gt;) between the cin and the variables.  The cin statement also does not check the input to verify that it is the correct type requested by the program nor does it allow for automatic prompting.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;h2&gt;&lt;span xmlns=&quot;&quot;&gt;Problems&lt;br /&gt;
&lt;/span&gt;&lt;/h2&gt;&lt;ol&gt;&lt;span xmlns=&quot;&quot;&gt;
&lt;li&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;Write a program to calculate the sum, difference, product, quotient, and remainder of two numbers from the user.  Be sure the user knows exactly what to input (i.e. use a prompt).&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;Modify Problem 1 to calculate the logical and, logical or, bitwise and, bitwise or, and bitwise xor of two numbers given by the user.  Be sure to use a prompt.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;Write a program to set x equal to the remainder of a1 and a2, set y equal to the quotient of b1 and b2 and set z equal to the sum of x and y (the sum should not equal 0!).  Print out each variable as well as a prompt on a line by themselves.  The values of a1, a2, b1, and b2 should be given by the user.&lt;/div&gt;&lt;/li&gt;
&lt;/span&gt;&lt;/ol&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;/span&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://rhale78.blogspot.com/feeds/5414220450736237491/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://rhale78.blogspot.com/2010/02/intro-to-computer-programming-chapter-6.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/270091469191232126/posts/default/5414220450736237491'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/270091469191232126/posts/default/5414220450736237491'/><link rel='alternate' type='text/html' href='http://rhale78.blogspot.com/2010/02/intro-to-computer-programming-chapter-6.html' title='Intro to Computer Programming - Chapter 6: Communicating with the Computer'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/09185478558704427023</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-270091469191232126.post-4933460924956019262</id><published>2010-02-26T17:52:00.000-05:00</published><updated>2010-02-26T17:52:00.106-05:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Intro to Computer Programming"/><title type='text'>Intro to Computer Programming - Chapter 5: Working with numbers</title><content type='html'>&lt;span xmlns=&quot;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;h2&gt;&lt;span xmlns=&quot;&quot;&gt;Introduction&lt;br /&gt;
&lt;/span&gt;&lt;/h2&gt;&lt;span xmlns=&quot;&quot;&gt;A computer&#39;s strength is in computing solutions to expressions.  An expression can be something as simple as 1+1 to as complex as.  [Don&#39;t expect me to explain that one to you! {it&#39;s not complete anyway!}].  Expressions are made up of numbers, operators, variables, and possibly functions.  Numbers have already been covered in an earlier chapter.  Operators, variables, and also some common math related functions will be covered in this chapter.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;h2&gt;&lt;span xmlns=&quot;&quot;&gt;Operators&lt;br /&gt;
&lt;/span&gt;&lt;/h2&gt;&lt;h3&gt;&lt;span xmlns=&quot;&quot;&gt;Introduction&lt;br /&gt;
&lt;/span&gt;&lt;/h3&gt;&lt;span xmlns=&quot;&quot;&gt;Anyone who has used addition, multiplication, subtraction, or division has used an operator.  An operator is a device used to convert one thing into another thing.  In modern math, operators normally come between one thing and another.  For example, the addition operator (+) comes between two numbers such as in 2 + 2.  In modern math, we use the symbols + for addition, - for subtraction, × for multiplication (or · in algebra), and ÷ for division.  In addition to the common four operators, we use parenthesis ( ( ) ) to indicate one thing has precedence over something else and we also use superscript numbers (ex: &lt;sup&gt;2&lt;/sup&gt;) to indicate a number to a power (2&lt;sup&gt;3&lt;/sup&gt;=8) and the root sign () is used to show the root of a number.  The operators that deal with numbers are called numerical operators.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;In addition to general math, computers also deal with logic.  Logic deals with whether something is true or false.  Most languages have a set of logical operators that deal with the evaluation of logical expressions.  For instance, say that A is true and B is true, then A AND B is true.  The most common logical operators are and, or, not, and exclusive or.  The logical operators return a value of true or false to indicate the solution to the logical expression.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;Computers also can tell if one value is less than (&amp;lt;), equal (=), or greater than (&amp;gt;) another value.  These operators are called relational operators.  Relational operators tell the relationship from one value to another.  These operators also return true or false depending upon the value of the expression.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;In addition to numerical operators, logical operators, and relational operators, a computer can also deal with the logical operators on a bit level.  Sometimes it is useful to find out of a certain bit is set or cleared and these bit-wise operators are useful for this task.  Qbasic does not directly support the bit-wise operators.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;h3&gt;&lt;span xmlns=&quot;&quot;&gt;Numerical Operators&lt;br /&gt;
&lt;/span&gt;&lt;/h3&gt;&lt;span xmlns=&quot;&quot;&gt;Most programming languages have each of these common math operators but the symbols may be different.  For instance, multiplication in most programming languages is the star (* {shift-8}).  Addition and subtraction are usually the normal symbols of + and – respectively.  Division is usually the forward slash (/).  Parenthesis are usually the same as in modern math.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;The power operator and the square root operator are usually different from one language family to another.  For example, in Qbasic, the power operator is the caret (^) and the root operator is also the caret.  In C and C++, neither the power operator nor the root operator exist as operators but they exist as functions.  Table 9 lists the common numerical operators in Qbasic and C/C++.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;table border=&quot;0&quot; style=&quot;border-collapse: collapse;&quot;&gt;&lt;colgroup&gt;&lt;col style=&quot;width: 127px;&quot;&gt;&lt;/col&gt;&lt;col style=&quot;width: 54px;&quot;&gt;&lt;/col&gt;&lt;col style=&quot;width: 53px;&quot;&gt;&lt;/col&gt;&lt;/colgroup&gt;&lt;tbody valign=&quot;top&quot;&gt;
&lt;tr&gt;&lt;td style=&quot;border: 0.5pt solid; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;b&gt;Math operator&lt;/b&gt;&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: solid solid solid none; border-width: 0.5pt 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;b&gt;Qbasic&lt;/b&gt;&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: solid solid solid none; border-width: 0.5pt 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;b&gt;C/C++&lt;/b&gt;&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;+ (addition)&lt;/span&gt;&amp;nbsp;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;+&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;+&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;- (negation)&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;-&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;-&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;- (subtraction)&lt;/span&gt;&amp;nbsp;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;-&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;-&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;× (multiplication)&lt;/span&gt;&amp;nbsp;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;*&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;*&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;÷ (division)&lt;/span&gt;&amp;nbsp;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;/&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;/&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;modulus (remainder)&lt;/span&gt;&amp;nbsp;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;mod&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;%&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;i&gt;power&lt;/i&gt;&lt;/span&gt;&amp;nbsp;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;^&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;n/a&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;(root)&lt;/span&gt;&amp;nbsp;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;^&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;n/a&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;b&gt;Table 9 - Math operators and Qbasic/C/C++ equivalents&lt;br /&gt;
&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Most of the operators in the above table should be familiar as most are common math operators.  The one operator that needs a little explanation is the modulus operator.  The modulus operator is a way of finding the remainder of two numbers as if they had been divided.  For instance, a normal division of 5 and 2 (5/2) is equal to 2.2 or 2 with a remainder of 1.  The modulus operator gives us 1 as the answer to 5 mod 2 since the remainder of 5/2 is 1.  There is actually a formula that can be used to find the modulus of two numbers and the steps for this formula are in Figure 2 (a is the first number, b is the second number).&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&lt;br /&gt;
&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;table border=&quot;0&quot; style=&quot;border-collapse: collapse;&quot;&gt;&lt;colgroup&gt;&lt;col style=&quot;width: 391px;&quot;&gt;&lt;/col&gt;&lt;/colgroup&gt;&lt;tbody valign=&quot;top&quot;&gt;
&lt;tr&gt;&lt;td style=&quot;border: 0.5pt solid; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;1. Divide a by b (ex: 5/2=2.2)&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;2. Subtract the answer by the answer after dropping the decimal&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;(ex: 2.2-2)&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;3. Multiply the answer from step 2 by b and drop the decimal (.2*2=1)&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;b&gt;Figure 2 - Modulus Calculation Steps&lt;br /&gt;
&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;h3&gt;&lt;span xmlns=&quot;&quot;&gt;Logical Operators&lt;br /&gt;
&lt;/span&gt;&lt;/h3&gt;&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Every modern day computer is based on electronic circuits called gates.  These gates deal with pure logic of zeros and ones.  The gates do a math similar to modern day math except with different rules.  There are roughly sixteen of these gates and most of them have names.  The most common of these gates are and, or, not, and exclusive or (xor).&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Most of these gates are familiar to us as English speaking humans.  For instance, if a person has a car and has a house then we know that that person has both a car and a house and does not just have one (such as only a car).  The only two that are different than our English are or and xor.  &lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;The or in English means that a person can do one thing or something else but does not mean that a person can do both.  For instance if a person says you could have an apple or an orange you must choose between the two but you can not have both.  This is not the case in the gate version of or.  Or in terms of gates means the same thing and and/or does in English in that a person can have an apple and/or an orange.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;Our English interpretation of or is the same as the gate version of exclusive or or xor.  Xor means one or the other but not both.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;The not gate basically reverses the logic.  For example, if a person has not a house and not a car [excuse the poor English, just go with it as it is] then we say that person does not have a house nor a car.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;Instead of sentences, these gates use electronic voltages to indicate the value of a statement.  Most of the time these values are either 1 or 0 or in other words they are binary.  Each of these gates and their values can be placed into a table that indicate what a value will be upon a certain input.  For instance, the value of 1 and 1 (or true and true) would equal 1 (true) but 1 and 0 would equal false.  The following tables illustrate each of the common gates as well as their output values given a set of input values.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&lt;br /&gt;
bAND01a000101Table 10 - AND gate&lt;br /&gt;
&lt;br /&gt;
bOR01a001111Table 11 - OR gate&lt;br /&gt;
&lt;br /&gt;
bXOR01a001110Table 12 - XOR gate&lt;br /&gt;
&lt;br /&gt;
NOTa0110Table 13 - NOT gate&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;It should be noted that all of the logical operators require two inputs, just as the general math operators do, with the exception of the not operator.&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;In C/C++, any number other than zero is true and zero is always false.  In Qbasic, only 1 and -1 are allowed for true and any other number is false.  On output, C/C++ will give 1 for true and 0 for false but Qbasic will give -1 or 1 for true and 0 for false.&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;In Qbasic and C/C++, these gates or logical operators can be used on a set of inputs.  In Qbasic, the logical operators are exactly the same name as the gates they represent, but in C/C++ they are completely different.  Table 14 lists the logical operators and their equivalent in the C/C++ language (notice that xor is not included because it does not directly exist as a logical operator).&lt;br /&gt;
Gate/logical operatorC/C++ EquivalentAND&amp;amp;&amp;amp;OR|| (double bar) &lt;br /&gt;
[same key as backslash]NOT!Table 14 - Logical operators and C/C++ equivalents&lt;br /&gt;
Relational Operators&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Relational operators are used to tell if one thing is less than, equal to, or greater than something else.  These operators are useful to tell how one number compares to another or even how strings or characters relate to each other.  Table 15 shows the relational operators in Qbasic and C/C++.&lt;br /&gt;
OperatorQbasicC/C++less-than&amp;lt;&amp;lt;less-than or equal&amp;lt;=&amp;lt;=greater-than&amp;gt;&amp;gt;greater-than or equal&amp;gt;=&amp;gt;=equal=== &lt;br /&gt;
(two equal signs)not equal&amp;lt;&amp;gt;!=Table 15 - Relational Operators in Qbasic and C/C++&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Notice how Qbasic uses the equals operator for equals but C/C++ use a double equals.  This is very important to remember as you&#39;ll see shortly.  Also notice how Qbasic uses &amp;lt;&amp;gt; for not equals but C/C++ use !=.  For C/C++ this actually makes sense as ! is the symbol for the not operator.&lt;br /&gt;
Bitwise Operators&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;The bitwise operators are used in C/C++ and many other languages to tell if a certain bit is set (1) or cleared (0) or to produce a different number by setting or clearing specific bits.  The bitwise operators can also be used to create encryption and decryption routines.&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;The bitwise operators are not available in Qbasic but are available in C/C++ and are listed in the following table.  Notice how the bitwise operators are similar to the logical operators.&lt;br /&gt;
Bitwise OperatorC/C++ EquivalentAND&amp;amp;OR| [same key as backslash (\)]XOR^Table 16 - Bitwise operators and C/C++ Equivalents&lt;br /&gt;
Order of Operations&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;In math, the order that the operators are completed in makes a big difference in the answer.  For example, 2+4*3 can be done two way, the first way gives 18 [addition first], the second way gives 14 [multiplication first], but which way is correct?  According to modern day algebra, the second way is correct and the correct answer to 2+4*3 is 14 not 18.  The reason for this is because multiplication and division are done first and addition and subtraction are done last.  If there are two of the same level of operations then the left most operation should be done first (ex: 2*3*4 should be 2*3 first and then 6*4 second), this is called left associative. This ordering of the operands is called the order of operations.  This ordering can be modified by using parenthesis such as (2+4)*3=18 and the 18 is correct in this instance.&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Programming languages also have an order of operations but this ordering is much more complex because any operator, numerical, logical, relational, or bitwise, can be used in an expression and in any combination.  This ordering is also made a little more complex due to the fact that some operators are left associative and some are right associative (rightmost first).  Of course, parenthesis can change the order of operations.  Table 17 shows the order of operations for Qbasic and for C/C++.&lt;br /&gt;
&lt;br /&gt;
OperatorQbasicC/C++LevelAssociativityNOTNOT!1RightNegative--1RightPower^n/a2LeftMultiply**3LeftDivide//3LeftRemainderMOD%3LeftAdd++4LeftSubtract--4LeftLess than&amp;lt;&amp;lt;5LeftLess than or Equal &amp;lt;=&amp;lt;=5LeftGreater than&amp;gt;&amp;gt;5LeftGreater than or Equal &amp;gt;=&amp;gt;=5LeftEqual===6LeftNot Equal&amp;lt;&amp;gt;!=6LeftBitwise ANDn/a&amp;amp;7LeftBitwise XORn/a^8LeftBitwise ORn/a|9LeftLogical ANDAND&amp;amp;&amp;amp;10LeftLogical OROR||11LeftLogical XORXORn/a12LeftAssignment==13RightTable 17 - Order of Operations for Qbasic and C/C++&lt;br /&gt;
Examples&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;The following table demonstrates the operators covered in this section and the output from Qbasic and C/C++.  In this table, 1 will equal true and 0 will equal false.  Notice the order of operations for complex expressions.  [line breaks in this table are not intentional but are the result of the equation being too long to fit in the box on a single line].&lt;br /&gt;
General &lt;br /&gt;
ExpressionQbasic&lt;br /&gt;
ExpressionC/C++&lt;br /&gt;
ExpressionAnswer2+4*822+4*8^22+4*(8*8)&lt;br /&gt;
[power n/a]2581 or not 0 and 11 OR NOT 0 AND 11||!0&amp;amp;&amp;amp;111 xor 11 XOR 1n/a0134 bitwise and 128n/a134&amp;amp;1281280+1 and 1-1 or 128 &lt;br /&gt;
-(150 bitwise and 127)n/a0+1&amp;amp;&amp;amp;1-1|| &lt;br /&gt;
128-(150&amp;amp;127)15 bitwise xor 3n/a5^366 bitwise xor 5n/a6^535÷05/05/0Illegal.&lt;br /&gt;
Division by zero&lt;br /&gt;
error!5&amp;lt;=10 and 5=&amp;gt;15 or 10&amp;lt;7 &lt;br /&gt;
and 3&amp;gt;0 &lt;br /&gt;
and not (15*3&amp;lt;18*2) &lt;br /&gt;
and 5=5&lt;br /&gt;
or 5 modulus 3=15&amp;lt;=10 AND 5&amp;gt;=15 &lt;br /&gt;
OR 10&amp;lt;7 AND &lt;br /&gt;
3&amp;gt;0 AND NOT &lt;br /&gt;
(15*3&amp;lt;18*2) AND &lt;br /&gt;
5=5 OR 5 MOD 3=15&amp;lt;=10 &amp;amp;&amp;amp; 5&amp;gt;=15 &lt;br /&gt;
|| 10&amp;lt;7 &amp;amp;&amp;amp; &lt;br /&gt;
3&amp;gt;0 &amp;amp;&amp;amp; ! &lt;br /&gt;
(15*3&amp;lt;18*2) &amp;amp;&amp;amp; &lt;br /&gt;
5==5 || 5 % 3==105 and 25 AND 25 &amp;amp;&amp;amp; 20 (Qbasic)&lt;br /&gt;
1 (C/C++)Table 18 - Example Expressions in Qbasic and C/C++&lt;br /&gt;
Variables&lt;br /&gt;
Introduction&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Just as operators are used in general math, variables are used in modern algebra.  A variable is a letter, symbol, or word used to take the place of a number or expression.  For example, in the expression x+4=8, the letter x is used to take the place of the number 4 (or possibly the expression 2+2 or even 22).  In computers, variables are used to hold information for later retrieval or to perform more calculations.&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Most programming languages restrict a variables name.  The variable must start with a letter and must not contain any punctuation or spaces.  The length of a variable must also be between 1 and 127 characters.  A variable name also must not be equal to the same name as a statement of that language.  For example, in Qbasic, a variable can not be the named print because one of Qbasic&#39;s statements is named print.&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;In math, variables usually hold a number or something that could eventually become a number.  In computers, a variable can be a number, a string, a picture, among many other things.  Since the computer does not know which type of information a variable will contain, the computer must be told what type of variable to create.  Telling the computer what type a variable is is called declaring a variables type.  The different types a variable can have is determined by the programming language being used, but the most common types are integers, characters, and floats.&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;In addition to declaring a variables type, the programmer must also declare a variables scope.  The scope tells where the variable will be known within the program.  As a comparison, the English language&#39;s scope is only within the countries that speak English whereas a laugh is within the global scope (anyone in the world can understand what a laugh is, even little babies).&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;It is sometimes useful to say that a certain variable must stay the same throughout a program to keep from accidentally changing its value.  Forcing a variable to remain the same is called making the variable constant.  Numbers are usually considered to be constants since a number can never change its value (the number 5 cannot change to the number 7 for instance, but the letter x could stand for 5 or for 7 and could change at any time).  Some uses for constants are the values of pi (π), the gravitational constant, number of ounces in a pound, and so on.&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;In most programming languages, variables, once changed, can not be changed back to what they previously were.  For example, if the variable x contains 5 and later is changed to 10, the 5 is permanently erased and x will equal to 10 and not 5.  There are a few ways around this limitation as will be seen in another chapter.  One easy way is to copy the variable into another variable before it is changed.&lt;br /&gt;
Declaring Variables in Qbasic&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Qbasic, as stated in the last chapter, is a beginners language and therefore is fairly easy on the programmer in declaring variables.  Qbasic does not require all variables to be declared and it automatically sets a value to each variable when it is first used [many languages do not do this for the programmer].&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;In Qbasic, the programmer only has to give a variable a name and the language will automatically declare the variable as a single precision type [unless overridden] when the variables is first used and will set the variable equal to 0.0.  What if the programmer did not want a single precision variable but wanted an integer instead?  This is where the variable type specifiers come into play.&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;A variable type specifier tells a language what type the variable will be.  In Qbasic, a variable can be an integer, single precision, double precision, long integer, string, or fixed-length string.  The variable type specifier in Qbasic is a symbol added to the end of the variable that tells Qbasic what type the variable is.  The symbols are the percent sign (%) for integers, dollar sign ($) for strings, number sign (#) for double precision, exclamation point (!) for single precision, and ampersand (&amp;amp;) for long integers.&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Variables are usually assigned a value when they are first created even though in Qbasic this is not necessary unless the programmer wants a variable to have a specific value.  Assigning a variable to a value can be done by using the equals operator (x=5 for instance sets x equal to 5).  A word of caution, the variable being assigned a value must be on the left of the equals sign by itself.  This is different from math where a variable could have an equation on the left side of the equals (example, x+4=8).&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Qbasic offers six different variable data types, four of which are numerical and two of which deal with strings.  The four numerical data types are integers, longs, single, and double and the two non-numerical data types are variable length strings and fixed length strings.&lt;br /&gt;
Integers in Qbasic are signed 16-bit numbers and are the fastest of the data types that Qbasic can handle.  The variable type specifier for the integer is the percent sign (%).  These variables are automatically initialized to 0 when they are created.&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Long integers in Qbasic are signed 32-bit numbers and are slower than integers but faster than the other numerical data types that Qbasic offers.  They are also initialized to 0 and the variable type specifier for long integers is the ampersand (&amp;amp;).&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Single precision numbers are the default type for variables created in Qbasic.  They are also one of the slowest in calculations.  They are 32-bits long and are floating point numbers.  Upon creation, they are initialized to 0.0.  The exclamation point (!) is the variable type specifier for single precision numbers.&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Double precision numbers are the slowest of the Qbasic data types.  They are 64-bit floating point numbers and they are initialized to 0.0 upon creation.  Their variable type specifier is the number sign (#).&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Qbasic offers two non-numerical data types and both of them deal with strings of  characters.  &lt;br /&gt;
The first type of string is the variable length string (string for short) and its variable type specifier is the dollar sign ($).  Variable length strings can contain anywhere from 0 up to 32,767 characters and are usually used for processing text.  They are automatically initialized to null [meaning nothing or blank].  When giving a string a value, the information must be enclosed in quotes (a$=&quot;Hello&quot;, not a$=Hello) otherwise Qbasic will think the value is a variable and not a string.  [note that if the programmer intends to assign one string variable to another, do not include the quotes].&lt;br /&gt;
The second type of strings that Qbasic offers is the fixed-length string.  Fixed length strings are fixed to a maximum specified size and they are not able to go above this size.  The fixed length string is more complex and will be covered later as it does not have a variable type specifier.  They are automatically initialized to null as well.  Fixed length strings are normally used for database applications or for advanced file access.&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Qbasic also allows the creation of constant variables.  In order for a variable to be constant, the command CONST must be before the name of the variable and the variable must be initialized to a specific value.  Once the variable is declared constant it can not be changed.&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;The scope of Qbasic variables is harder to explain and will be covered when the scope comes into play.  It can be assumed that all variables up to and including this chapter are global.&lt;br /&gt;
The following table demonstrates declaring variables in Qbasic.  Note that each box represents a completely different program and does not depend upon a previous box&#39;s contents.&lt;br /&gt;
StatementCommentPRINT xx will be declared by Qbasic as&lt;br /&gt;
a single precision variable and will&lt;br /&gt;
contain 0.0 but will be printed as 0.x$=&quot;A&quot;x will be declared as a string and &lt;br /&gt;
will contain the capital letter A.x=5x will be declared as a single &lt;br /&gt;
precision variable and will contain &lt;br /&gt;
the number 5.x=y&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
y=3x and y will be declared as single &lt;br /&gt;
precision variables (y will be &lt;br /&gt;
declared first and be set to a &lt;br /&gt;
value of 0.0).  x will be set to the &lt;br /&gt;
value of y and both will contain 0.0.&lt;br /&gt;
y will equal 3.  Note that x does &lt;br /&gt;
not change just because y did.x%=0.9x will be declared as an integer an &lt;br /&gt;
will contain the value 0.  Note that &lt;br /&gt;
the decimal is dropped and not rounded.x=&quot;A&quot;x will be declared as a single precision&lt;br /&gt;
variable and Qbasic will attempt to &lt;br /&gt;
assign the capital letter A to it but will&lt;br /&gt;
fail and will give a type mismatch error.x$=yx will be declared as a string variable &lt;br /&gt;
and Qbasic will attempt to assign &lt;br /&gt;
the newly created single precision y &lt;br /&gt;
variable to it but will fail and will &lt;br /&gt;
give a type mismatch error.x&amp;amp;=x%+1x% will be declared and initialized &lt;br /&gt;
to 0, 1 will be added to x% and &lt;br /&gt;
that value will be assigned to x&amp;amp;.  &lt;br /&gt;
Notice how two variables have the &lt;br /&gt;
exact same name but different types, &lt;br /&gt;
this is allowed in Qbasic but is NOT &lt;br /&gt;
recommended.x=x+1The x variable on the right will be &lt;br /&gt;
declared as a single precision &lt;br /&gt;
variable and will be initialized &lt;br /&gt;
to 0.  1 will be added to it and &lt;br /&gt;
the sum will be assigned to the &lt;br /&gt;
x variable on the left of the &lt;br /&gt;
equals.  Notice that this statement &lt;br /&gt;
is not allowed in normal math but &lt;br /&gt;
is perfectly legal in programming. &lt;br /&gt;
This in a sense increases x by 1.CONST pi=3.14&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
pi=3Creates a single precision variable &lt;br /&gt;
called pi that is declared constant &lt;br /&gt;
and is initialized to 3.14.&lt;br /&gt;
Generates a duplicate definition &lt;br /&gt;
error since pi is declared constant.Table 19 - Qbasic Variable Declaration Examples&lt;br /&gt;
Declaring Variables in C/C++&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Unlike Qbasic, C and C++ both requires all variables to be declared and it also requires all variables to be initialized.  One of the common mistakes most programmers make is the use of uninitialized variables.  The C/C++ language does not set a newly created variable to any specific value but leaves the value so it is the sole job of the programmer to do this.  Again, C/C++ requires all variables to be declared and it does not have a default type for undeclared variables as all variables must be specifically declared.&lt;br /&gt;
C/C++ has several numerical variable data types but only one non-numerical type.  The numerical variable types that C/C++ support are bytes, short integers, integers, floats, longs integers, doubles, and Booleans.  The non-numerical type that C/C++ supports is the character.  All of these data types in C/C++ can be signed or unsigned but defaults to signed values.&lt;br /&gt;
Unlike Qbasic, the C/C++ variable type specifiers come before the name of the variable and must include a space between the variable type specifier and the variable name.  Table 20 shows the variable type, their normal sizes, and the variable type specifiers.&lt;br /&gt;
&lt;br /&gt;
TypeSize &lt;br /&gt;
in bitsVariable Type &lt;br /&gt;
Specifierbyte8byteshort integer16shortinteger32&lt;br /&gt;
(depends&lt;br /&gt;
on processor)intlong integer64&lt;br /&gt;
(depends&lt;br /&gt;
on processor)longfloat32floatdouble64doubleBoolean1&lt;br /&gt;
(depends&lt;br /&gt;
on compiler)boolcharacter8charTable 20 - C/C++ Variable Type Specifiers&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;The main difference between Qbasic and C/C++ variable initialization is the initiation of the char type.  In Qbasic, strings are initialized by putting the information in quotes (&quot;).  In C/C++, the char type is initialized by inserting the information in single quotes (&#39;) [same key as double quotes (&quot;)] instead of double quotes.  Another interesting thing to note about the char type is that it can be assigned a number instead of a character.  In this case, the number would represent the ASCII code for a specific character.  When printed, the character would be displayed but in mathematical formulas the character would be treated as if it were a number.&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;In C/C++, a variable can be declared signed or unsigned.  To do this, the word signed or unsigned must come before the variable type specifier.  The default for all of C/C++&#39;s types is signed.&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Variables in C/C++ can also be declared constant and are declared constant the same way Qbasic variables are declared constant.  The word const must come before the sign specifier and before the variable type specifier.  As in Qbasic, the variable must be initialized upon creation and is not allowed to be changed.&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;The scope of a variable within C/C++ is more easily defined than it is in Qbasic.  In C/C++, a variable&#39;s scope is only between the opening brace ({) that comes before it and the matching closing brace (}).  If the programmer wishes to create a global variable, the variable must be declared outside of any brace pairs [preferably at the beginning of the program after the include directives].  Global variables are the exception to the initialization rule in that they are automatically initialized to a default value, similar to the way Qbasics variables are initialized.  Global variable are frowned upon in programming.&lt;br /&gt;
The following table demonstrates declaring variables in C/C++.  Note that each box represents a completely different program and does not depend upon a previous box&#39;s contents.  Also note that most of these are not complete programs but only segments of code.&lt;br /&gt;
ProgramCommentsint x;Creates a signed integer &lt;br /&gt;
variable named x.  Note &lt;br /&gt;
that the variable contents&lt;br /&gt;
are unknown and could &lt;br /&gt;
change each time the program&lt;br /&gt;
is executed!unsigned short y=0;Creates an unsigned short &lt;br /&gt;
variable named y and it is &lt;br /&gt;
initialized to 0.double y=1.4;&lt;br /&gt;
int x=0;&lt;br /&gt;
x=y;Creates a signed double &lt;br /&gt;
variable named y and &lt;br /&gt;
initializes it to 1.4&lt;br /&gt;
Creates a signed integer &lt;br /&gt;
variable named x and &lt;br /&gt;
initializes it to 0.&lt;br /&gt;
Compiler will give a &lt;br /&gt;
warning saying that y is &lt;br /&gt;
not an integer [possibly &lt;br /&gt;
an error].  A type cast should&lt;br /&gt;
be used (see function section){&lt;br /&gt;
int x=1;&lt;br /&gt;
{&lt;br /&gt;
cout&amp;lt;&amp;lt;x;&lt;br /&gt;
}&lt;br /&gt;
}Since the cout is after the &lt;br /&gt;
declaration of x and since x&lt;br /&gt;
is within the same scope as the&lt;br /&gt;
cout, a 1 will be printed.{&lt;br /&gt;
int x=1;&lt;br /&gt;
}&lt;br /&gt;
{&lt;br /&gt;
cout&amp;lt;&amp;lt;x;&lt;br /&gt;
}Compiler will give an undeclared&lt;br /&gt;
variable error since x is outside&lt;br /&gt;
the scope on the cout statement.const unsigned double pi=3.14;Creates a constant unsigned &lt;br /&gt;
double variable named pi &lt;br /&gt;
and is equal to 3.14.  Note that &lt;br /&gt;
pi can not be changed otherwise &lt;br /&gt;
the compiler will give an error.int x=1;&lt;br /&gt;
double x=5;Compiler will give an error&lt;br /&gt;
saying that x is already declared.char v=&#39;A&#39;;&lt;br /&gt;
char x=66;&lt;br /&gt;
cout&amp;lt;&amp;lt;v&amp;lt;&amp;lt;endl;&lt;br /&gt;
v=v+2;&lt;br /&gt;
cout&amp;lt;&amp;lt;x&amp;lt;&amp;lt;endl;&lt;br /&gt;
cout&amp;lt;&amp;lt;v;Creates two character variables, &lt;br /&gt;
one named v and one named x &lt;br /&gt;
and initializes both of them, &lt;br /&gt;
v to the capital letter A and &lt;br /&gt;
x to the ASCII code 66 [letter&lt;br /&gt;
B].  Prints out the contents of &lt;br /&gt;
v, adds two to v and then prints&lt;br /&gt;
out the contents of x, then prints&lt;br /&gt;
the contents of v.  Program &lt;br /&gt;
prints A B and C [each letter &lt;br /&gt;
on a separate line].int a;&lt;br /&gt;
a=1;Creates an signed integer &lt;br /&gt;
variable named a.  The variable &lt;br /&gt;
a is not initialized until the &lt;br /&gt;
second line.int x, y;Creates two signed uninitialized&lt;br /&gt;
integers x and y.int x=0, y=1;Creates two signed integers, &lt;br /&gt;
x and y and initializes x to 0 &lt;br /&gt;
and y to 1.int x,y;&lt;br /&gt;
x=15;&lt;br /&gt;
y=(x==15);Creates two signed uninitialized&lt;br /&gt;
integers x and y.  Assigns 15 to x.&lt;br /&gt;
Checks for equality between x and 15 &lt;br /&gt;
(i.e. does x equal 15).  Sets y equal&lt;br /&gt;
to 1 (true) since x equals 15.int x,y,z;&lt;br /&gt;
z=5;&lt;br /&gt;
x=y=z;Creates three signed uninitialized&lt;br /&gt;
integers x, y, and z.  Sets z=5.  &lt;br /&gt;
Sets y equal to z then sets x equal to y.int x=1;&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
cout&amp;lt;&amp;lt;x&amp;lt;&amp;lt;endl;&lt;br /&gt;
}Creates a global signed integer variable&lt;br /&gt;
and initializes it to 1.  Since it is global, &lt;br /&gt;
the cout is able to print out its value.Table 21 - C/C++ Variable Declaration Examples&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;One important thing to remember in C/C++ is the difference between equals (=) and double equals (==).  In C/C++, the equals sign assigns a value to a variable such as in x=5.  The double equals, on the other hand, tests for equality such as to see if x does equal 5.  The equality operator is a relational operator and therefore gives a 1 or 0 back.  The equals operator is an assignment and it gives the value on the right of the equal sign back.  Common programming mistakes happen because the programmer put an assignment operator equals in place of the relational operator double equals.&lt;br /&gt;
Functions&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Functions are formulas or equations that take one or more values and gives one value back.  High school Algebra has functions such as the absolute value of a number.  The absolute value function take one number, such as -5, and gives back its positive form, in this case 5.  Trigonometry is another section of mathematics that contains many functions such as the sine, cosine, and tangent of an angle.&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Most programming languages also contain functions, most of which work on numbers such as the absolute value, sine, and logarithm.  Most languages also contain functions that work on strings such as the length of a string or the left or right of a string.&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Both Qbasic and C/C++ have a subsection of math functions that can be used in expressions to perform a calculation.  Most math related functions only require one number, or parameter, and all will give back, or return, a single number.  Table 22 shows a list of common math related functions in Qbasic and in C/C++ and also what the functions return.  Variables x and y are used as inputs to the function.  Note that if these functions are used in C/C++, the math.h file must be included in the program using the #include directive.&lt;br /&gt;
&lt;br /&gt;
Function nameQbasicC/C++DescriptionAbsolute value(x)ABS(x)abs(x)Returns the absolute value of x.&lt;br /&gt;
If x&amp;lt;0 then it returns the positive&lt;br /&gt;
version of x.Sign(x)SGN(x)n/aReturns -1 if x&amp;lt;0, 0 if x=0 and 1 if x&amp;gt;0.Sine(x)SIN(x)sin(x)Returns the sine of x.  x must &lt;br /&gt;
be in radians not degrees.Cosine(x)COS(x)cos(x)Returns the cosine of x.  x &lt;br /&gt;
must be in radians not degrees.Tangent(x)TAN(x)tan(x)Returns the tangent of x.  x &lt;br /&gt;
must be in radians not degrees.Logarithm(x)LOG(x)log(x)Returns the log10 of x.Power(x,y)n/apow(x,y)Returns xySquare Root(x)SQR(x)sqrt(x)Returns the Random(x)RND(x)rand(x)Returns a pseudo random number.&lt;br /&gt;
Qbasic and C/C++ differ on the&lt;br /&gt;
meanings of x.Convert to integer(x)CINT(x)int(x)Convert x into an integer.Convert to double(x)CDBL(x)double(x)Convert x into a doubleConvert to single(x)CSNG(x)float(x)Convert x into a floatTable 22 - Common Math Functions in Qbasic and C/C++&lt;br /&gt;
Conclusion&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Expressions when used in a program are similar to equations in math in that they both have numbers, operators and possibly functions.  As in math, each operator also has a specific precedence level that it must obey in order to get the correct answer to an expression and these precedence levels can be overridden by the use of parenthesis.&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Variables are used in expressions just as variables are used in formulas.  Variables in programs are slightly different in that the variable on the left of the equals sign is not used as part of the expression and therefore statements such as x=x+1 are legal and can be solved or evaluated.&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;There are many different functions in most languages, several of which perform math related functions such as absolute value and sine.  Functions take in parameters and give back, or return, a value related to the parameter.&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Some examples that summarize this chapter are included in the following table.  Note that many of the C/C++ solutions are not complete programs but are code segments.&lt;br /&gt;
EquationQbasicC/C++Value(1+1)*(5+3)PRINT (1+1)*(5+3)cout&amp;lt;&amp;lt;(1+1)*(5+3);1628+3PRINT 2^8+3#include &amp;lt;math.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
cout&amp;lt;&amp;lt;pow(2,8)+3;&lt;br /&gt;
return 0;&lt;br /&gt;
}259Abs(-20)-20PRINT ABS(-20)-20#include &amp;lt;math.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
cout&amp;lt;&amp;lt;abs(-20)-20;&lt;br /&gt;
return 0;&lt;br /&gt;
}0x=true&lt;br /&gt;
y=false&lt;br /&gt;
z=not(x)&lt;br /&gt;
x and y and zx=1&lt;br /&gt;
y=0&lt;br /&gt;
z=NOT(x)&lt;br /&gt;
PRINT x AND y AND zbool x=1;&lt;br /&gt;
bool y=0;&lt;br /&gt;
bool z=!(x);&lt;br /&gt;
cout&amp;lt;&amp;lt;(x&amp;amp;&amp;amp;y&amp;amp;&amp;amp;z);0x=5&lt;br /&gt;
y=4&lt;br /&gt;
(x/y-int(x/y))*yx=5&lt;br /&gt;
y=4&lt;br /&gt;
PRINT (x/y-cint(x/y))*yint x=5;&lt;br /&gt;
int x=4;&lt;br /&gt;
cout&amp;lt;&amp;lt;((x/y-int(x/y))*y);1x=1&lt;br /&gt;
y=5&lt;br /&gt;
Does x+4=y?x=1&lt;br /&gt;
y=5&lt;br /&gt;
PRINT x+4=yint x=1;&lt;br /&gt;
int y=5;&lt;br /&gt;
cout&amp;lt;&amp;lt;(x+4==y);1Table 23 - Sample Expressions in Qbasic and C/C++&lt;br /&gt;
Problems&lt;br /&gt;
What are the solutions to the following expressions:&lt;br /&gt;
2+1*8x+9=1 (Qbasic)-1*5-(5+2)1 and 4 (Qbasic)2&amp;amp;10int(.25)*42|5abs(-25)*42^7 (xor)pow(2,3)sgn(-19)*sgn(12)+sgn(0)x=y=z=w=2 (C/C++)What are the values of x, y, and z in the following code segments?  [each box represents a different program]&lt;br /&gt;
int x;int x, y, z;&lt;br /&gt;
x=y=z=-1;x%=0x+1+yPRINT Y$int x;&lt;br /&gt;
x=x+1;x+y!y=1 and not 0short x=0;&lt;br /&gt;
int y=x;&lt;br /&gt;
x=5;int x=1;&lt;br /&gt;
int y=5;&lt;br /&gt;
int z=x*y+z;Write a program to calculate the sum, difference, product, quotient, and remainder of 5 and 2.&lt;br /&gt;
Modify Problem 3 to calculate the logical and, logical or, bitwise and, bitwise or, and bitwise xor of 5 and 7.&lt;br /&gt;
&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;ol&gt;&lt;span xmlns=&quot;&quot;&gt;
&lt;li&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;Write a program to set x equal to the remainder of 5 and 3, set y equal to the quotient of 4 and 7 and set z equal to the sum of x and y (the sum should not equal 0!).  Print out each variable as well as a prompt on a line by themselves.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;Besides the and, or, and xor gates in electronics there are nand gates, nor gates, and nxor gates.  These gates are the exact opposite of the and, or, and xor gates.  Write a program to produce the nand, nor, and nxor gates and verify that they work correctly.  Produce a complete table for each gate.  [the input a must equal 0 and 1, and b must equal 0 and 1].  {warning, this program will be large}&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;The table below lists several variable names.  Which of these variables is illegal and in which languages?&lt;/div&gt;&lt;/li&gt;
&lt;/span&gt;&lt;/ol&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;table border=&quot;0&quot; style=&quot;border-collapse: collapse;&quot;&gt;&lt;colgroup&gt;&lt;col style=&quot;width: 87px;&quot;&gt;&lt;/col&gt;&lt;col style=&quot;width: 73px;&quot;&gt;&lt;/col&gt;&lt;col style=&quot;width: 85px;&quot;&gt;&lt;/col&gt;&lt;/colgroup&gt;&lt;tbody valign=&quot;top&quot;&gt;
&lt;tr&gt;&lt;td style=&quot;border: 0.5pt solid; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;hi&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: solid solid solid none; border-width: 0.5pt 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;1.1&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: solid solid solid none; border-width: 0.5pt 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;Name1&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;maximum&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;and&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;city and state&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;print&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;cout&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;address&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;port20&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&#39;name&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;Color_blue&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;file.extension&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;program21&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;1st&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://rhale78.blogspot.com/feeds/4933460924956019262/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://rhale78.blogspot.com/2010/02/intro-to-computer-programming-chapter-5.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/270091469191232126/posts/default/4933460924956019262'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/270091469191232126/posts/default/4933460924956019262'/><link rel='alternate' type='text/html' href='http://rhale78.blogspot.com/2010/02/intro-to-computer-programming-chapter-5.html' title='Intro to Computer Programming - Chapter 5: Working with numbers'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/09185478558704427023</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-270091469191232126.post-8884155680176623476</id><published>2010-02-26T17:51:00.000-05:00</published><updated>2010-02-26T17:51:00.044-05:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Intro to Computer Programming"/><title type='text'>Intro to Computer Programming - Chapter 4: Communicating with the User</title><content type='html'>&lt;span xmlns=&quot;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;h1&gt;&lt;span xmlns=&quot;&quot;&gt;Chapter 4: Communicating with the User&lt;br /&gt;
&lt;/span&gt;&lt;/h1&gt;&lt;h2&gt;&lt;span xmlns=&quot;&quot;&gt;Introduction&lt;br /&gt;
&lt;/span&gt;&lt;/h2&gt;&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;One of the most common and basic of things a computer program can do is print information to the screen.  With the exclusion of sound output, output to the printer, or graphics, information printed to the screen is the only way to communicate with the user.  Every language (with the exclusion of assembly) has at least one specific command to print information to the screen, most have several.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;Nearly all of the commands of the HTML language are for displaying information in one form or another, whether it be in the form of text, audio, or in the form of graphics.  This is an advantage when displaying pre-processed information is the only thing the computer needs to deal with, but this is not usually the case.  For instance, in HTML alone, the programmer cannot ask the user for two numbers and add them together.  In other words, HTML cannot do any type of information processing.  This is where the other computer languages such as BASIC, C++, and Java come in.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;The next most common task that a computer does is ask the user for information and then process that information.  For instance, the older computers when turned on would ask the user for the current date and time and then they would act upon that information accordingly.  Even with modern computers running the Windows Operating System, the computer is constantly displaying information, asking the user for input, and doing background processing of the input.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;In an attempt to keep the programs simple at first, I&#39;ll only explain how to do text output and input.  The more advanced topics such as sound and graphics will be covered at a later time.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;h2&gt;&lt;span xmlns=&quot;&quot;&gt;Displaying Text in Qbasic&lt;br /&gt;
&lt;/span&gt;&lt;/h2&gt;&lt;h3&gt;&lt;span xmlns=&quot;&quot;&gt;Introduction&lt;br /&gt;
&lt;/span&gt;&lt;/h3&gt;&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Qbasic is one of the easier languages to write programs in.  Qbasic is based on the BASIC family of languages.  The BASIC language itself was created in the late 1960&#39;s for beginners so they could learn how to program (&lt;b&gt;BASIC&lt;/b&gt; stands for &lt;b&gt;Beginners All-Purpose Symbolic Instruction Code&lt;/b&gt;).&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;Unlike other languages, including HTML, Qbasic does not require any special requirements such as the requirements at the beginning or end of the program (like HTML requires the &amp;lt;html&amp;gt; and &amp;lt;/html&amp;gt; tags at the beginning and end of the program).  With Qbasic, the programmer can just start solving the problem.  Qbasic also is not an extremely strict language in that commands do not have to be capitalized and the language is not case-sensitive (for example, Name is the same thing as NAME and name).&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Qbasic programs do require the Qbasic interpreter, which is included on the enclosed CD under the Qbasic directory.  Microsoft created Qbasic as a free version of their compiler called QB.  The only difference is that any program created in Qbasic must be run within Qbasic because Qbasic must interpret each of the commands into something the computer can understand (similar to how a Spanish interpreter interprets English into Spanish).  QB, on the other hand, converts the program straight into a language the computer can understand so the program can be ran from Dos or from within Windows without the need for QB.  Any programs written in Qbasic will also work correctly in QB without problems, but not necessarily the other way around.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;There are at least two main reasons why Qbasic is not used to do much programming.  The first reason is because Qbasic is extremely slow in processing information.  The main reason for this is because it is an interpreted language and the process of interpreting one language into another is always slow, even when talking about human spoken languages.  The other reason why Qbasic is not used much is that it has limits as to how large the programs can be and how much data the program can handle.  Qbasic can only handle programs up to 64 kilobytes (one kilobyte is equal to 1,024 bytes) or roughly 64 typed pages.  Many programs are in order of several thousand typed pages long and Qbasic would not be able to even load the program, must less run it.  &lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;h3&gt;&lt;span xmlns=&quot;&quot;&gt;The Print Statement&lt;br /&gt;
&lt;/span&gt;&lt;/h3&gt;&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;In Qbasic, the Print statement is used to display text to the screen.  It can be used to print strings, numbers, and even the answers to formulas.  The format of the command is the command itself [i.e. PRINT] followed by what the programmer wishes to print.  If the programmer wants a certain piece of information printed &quot;as is&quot;, the information must be enclosed in quotes (&quot; &quot;).  To print a blank line, use a print statement by itself with nothing after it.  See Program 7 for examples of the print statement.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;table border=&quot;0&quot; style=&quot;border-collapse: collapse;&quot;&gt;&lt;colgroup&gt;&lt;col style=&quot;width: 158px;&quot;&gt;&lt;/col&gt;&lt;/colgroup&gt;&lt;tbody valign=&quot;top&quot;&gt;
&lt;tr&gt;&lt;td style=&quot;border: 0.5pt solid; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;PRINT &quot;Hello&quot;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;PRINT 2.14&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;PRINT 2+2&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;PRINT &quot;2+2&quot;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;PRINT&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;PRINT –2&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;PRINT 2/.5&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;PRINT 2.0&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;&lt;i&gt;Hello&lt;br /&gt;
&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;&lt;i&gt; 2.14&lt;br /&gt;
&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;&lt;i&gt; 4&lt;br /&gt;
&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;&lt;i&gt;2+2&lt;br /&gt;
&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;&lt;i&gt;-2&lt;br /&gt;
&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;&lt;i&gt; 4&lt;br /&gt;
&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;&lt;i&gt; 2&lt;/i&gt;&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;b&gt;Program 7 - Qbasic Program Showing Print Statement and Output&lt;br /&gt;
&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Qbasic is one of the few languages that actually helps its programmers out by giving them shortcuts.  One of the most famous shortcuts in the Qbasic is instead of always typing PRINT for each print statement, the programmer can just type a question mark and Qbasic will replace the question mark automatically with the print command.  Also helpful is the way Qbasic automatically capitalizes its commands as the programmer types them.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Notice that each print statement prints its output on a single line and then automatically goes to the next line.  If the programmer wishes to keep the output of the next print statement on the same line, just add a semicolon (;) to the end of the statement and Qbasic will keep any more output on the same line.  Another use of the semicolon option is to string several print statements into a single statement.  This could be useful if the type of data is different or if variables are involved (will explain variables in the next chapter).&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Another useful option with the print statement is the comma (,).  The comma is used just like the semicolon except that the comma adds a 16-space tab along with keeping everything on the same line.  The comma option is useful for doing tables.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;It is also useful to notice that positive numbers have a space inserted in front of them, but negative numbers to not have this additional space.  There is a way to get rid of this additional space, but you&#39;ll have to wait a couple chapters for the solution to that problem &lt;span style=&quot;font-family: Wingdings;&quot;&gt;J&lt;/span&gt;.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;The next program shows the use of the semicolon option as well as the question mark shortcut.  Notice how the words &quot;is&quot; and &quot;Raleigh&quot; do not have a space between them.  This is because the information enclosed within quotes is printed exactly as it is within the quotes.  To correct this apparent error, just add a space between the word is and the end quotation mark or before the quotation mark and the word Raleigh.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&lt;br /&gt;
&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;table border=&quot;0&quot; style=&quot;border-collapse: collapse;&quot;&gt;&lt;colgroup&gt;&lt;col style=&quot;width: 551px;&quot;&gt;&lt;/col&gt;&lt;/colgroup&gt;&lt;tbody valign=&quot;top&quot;&gt;
&lt;tr&gt;&lt;td style=&quot;border: 0.5pt solid; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;? &quot;The sum of 2+2=&quot;;2+2&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;?&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;? &quot;The capital of North Carolina is&quot;;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;? &quot;Raleigh&quot;;&quot; with a population of&quot;;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;? 200000&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 10pt;&quot;&gt;&lt;i&gt;The sum of 2+2= 4&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;
&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 10pt;&quot;&gt;&lt;i&gt;The capital of North Carolina isRaleigh with a population of 200000&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;b&gt;Program 8 - Qbasic Program Showing the use of ; and ?&lt;br /&gt;
&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;The print statement will come in handy in other forms of output in the Qbasic language.  You&#39;ll see the print statement again at a later time.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;h2&gt;&lt;span xmlns=&quot;&quot;&gt;Displaying Text in C&lt;br /&gt;
&lt;/span&gt;&lt;/h2&gt;&lt;h3&gt;&lt;span xmlns=&quot;&quot;&gt;Introduction&lt;br /&gt;
&lt;/span&gt;&lt;/h3&gt;&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;The C language is what some consider to be a professional language.  Most of todays programs are written in C or C++ (C++ is an advanced version of C).  C is not a beginners language like BASIC is but it doesn&#39;t suffer from the same restrictions as BASIC suffers from such as program size limits or data size limits.  For instance, the Windows Operating System is written mainly in C and C++ and contains several million lines of code.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;In order to write and compile C programs, the programmer must have a C compiler such as Microsoft Visual C++, Bloodshead&#39;s DevC++, or the GNU C compiler (the latter two are free).  The Bloodshead DevC++ compiler is located on the CD under the DevC directory.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;Unlike Qbasic, C is not an interpreted language but it is a compiled language.  This means that the compiler itself is not required after the first compile.  In other words, once the translation to the computer&#39;s native language is finished, it does not have to be translated again unless the program is changed.  This allows C compiled programs to be extremely fast when they are executed.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;C, like HTML and most other programming languages, has a minimum requirement for all of its programs.  This requirement does have a few parts that can be changed, but the beginning C programmer will not usually need these advanced features.  The requirements for C are exactly the same as those for its advanced version, C++.  Program 9 shows the minimum C/C++ program.  It is best to ignore what each line in Program 9 does at this time as each line will be explained later.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;table border=&quot;0&quot; style=&quot;border-collapse: collapse;&quot;&gt;&lt;colgroup&gt;&lt;col style=&quot;width: 158px;&quot;&gt;&lt;/col&gt;&lt;/colgroup&gt;&lt;tbody valign=&quot;top&quot;&gt;
&lt;tr&gt;&lt;td style=&quot;border: 0.5pt solid; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;int main( )&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;{&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    return 0;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;}&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;b&gt;Program 9 - Minimum C/C++ Program&lt;br /&gt;
&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Unlike Qbasic, C is case sensitive in both its commands as well as variables.  This means that main is not the same thing as Main or MAIN.  This is a common error for many beginning programmers.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Formatting is also fairly specific in C.  Nearly every line in C will require a semicolon at the end of the line.  There are a few exceptions and these will be covered in a later chapter.  Think of the requirement of the semicolon in C to be like the requirement of a period at the end of a sentence in the English language.  For now, just follow the examples on the uses of the semicolon placement.  They&#39;ll be explained soon.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;h3&gt;&lt;span xmlns=&quot;&quot;&gt;The printf Function&lt;br /&gt;
&lt;/span&gt;&lt;/h3&gt;&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;The C command to print information to the screen is somewhat similar to the print statement in Qbasic.  The printf function, with a few exceptions, will print text that is enclosed in quotes exactly as is, just like Qbasic.  The prinf function will also print numbers, but it requires some special formatting commands in order to work correctly.  Unlike print in Qbasic, printf automatically keeps all information on the same line unless told otherwise (this is the exact opposite of Qbasic). &lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;There is one requirement to add to the program before the printf statement can be used, &lt;span style=&quot;font-family: Courier New;&quot;&gt;#include &amp;lt;stdio.h&amp;gt;&lt;/span&gt;.  This additional line of code only needs to be added once and should be added at the beginning of the program.  The reason this additional line of code must be added is because C is a very small language and only has about 30 statements in the language [In comparison, Qbasic has over 200 statements].  In C, statements are automatically included in the language, but functions are not included unless you specifically tell C to add the function by using the #include directive.  As an example, let&#39;s say someone is trying to cook a specific kind of cake and they have ten different recipe books, all of which have different cakes in them and the recipe they want is in only one of these recipe books.  They would either have to search through all the books manually, be told by someone else which book its in, or look at an index.  The easiest way is for someone else who already knows the recipe books to tell them which book the specific cake recipe is located in (maybe the cook is in a hurry and needs the recipe quickly).  This is the case with the C language, the language (more specifically the compiler itself) must be told where the function is located.  In our case, the printf function is located in the file stdio.h.  The #include directive will be covered in depth later.  Program 10 demonstrates the printf statement and the #include directive.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;table border=&quot;0&quot; style=&quot;border-collapse: collapse;&quot;&gt;&lt;colgroup&gt;&lt;col style=&quot;width: 274px;&quot;&gt;&lt;/col&gt;&lt;/colgroup&gt;&lt;tbody valign=&quot;top&quot;&gt;
&lt;tr&gt;&lt;td style=&quot;border: 0.5pt solid; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;br /&gt;
&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;int main ( )&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;{&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    printf(&quot;This is C.&quot;);&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    return 0;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;}&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;&lt;i&gt;This is C.&lt;/i&gt;&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;b&gt;Program 10 - Simple printf Statement&lt;br /&gt;
&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;The printf function allows special formatting characters within quoted information.  As a contrast, Qbasic prints the quoted information exactly as is.  These special formatting characters force the printf statement to force a new line, insert a tab, among several others.  The most common of these are forcing a new line (\n) and the tab (\t) character.  Table 4 lists some of the special formatting characters that are available within the quoted text of the printf function and Program 11 demonstrates how they can be used in printf statements.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;table border=&quot;0&quot; style=&quot;border-collapse: collapse;&quot;&gt;&lt;colgroup&gt;&lt;col style=&quot;width: 121px;&quot;&gt;&lt;/col&gt;&lt;col style=&quot;width: 113px;&quot;&gt;&lt;/col&gt;&lt;/colgroup&gt;&lt;tbody valign=&quot;top&quot;&gt;
&lt;tr&gt;&lt;td style=&quot;border: 0.5pt solid; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;b&gt;Format Character&lt;/b&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: solid solid solid none; border-width: 0.5pt 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;b&gt;Meaning in C&lt;/b&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 12pt;&quot;&gt;\n&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;Insert a new line&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;\t&amp;nbsp;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;Insert a tab&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;\\&amp;nbsp;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;Print out a \&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;\&quot;&amp;nbsp;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;Print a &quot;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;b&gt;Table 4 - Printf format characters&lt;br /&gt;
&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;table border=&quot;0&quot; style=&quot;border-collapse: collapse;&quot;&gt;&lt;colgroup&gt;&lt;col style=&quot;width: 552px;&quot;&gt;&lt;/col&gt;&lt;/colgroup&gt;&lt;tbody valign=&quot;top&quot;&gt;
&lt;tr&gt;&lt;td style=&quot;border: 0.5pt solid; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;br /&gt;
&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;int main( )&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;{&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    printf(&quot;The capital of North Carolina is&quot;);&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    printf(&quot;Raleigh\n&quot;);&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    printf(&quot;\tThis sentence has a tab in front\n\n&quot;);&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    printf(&quot;\n&quot;);&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    printf(&quot;The file is located in C:\\My Files\n\n&quot;);&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    printf(&quot;C is \&quot;fun\&quot;\n&quot;);&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    return 0;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;}&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;&lt;i&gt;The capital of North Carolina isRaleigh&lt;br /&gt;
&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;&lt;i&gt;        This sentence has a tab in front&lt;br /&gt;
&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;&lt;i&gt;The file is located at C:\My Files&lt;br /&gt;
&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;&lt;i&gt;C is &quot;fun&quot;                                                                     &lt;/i&gt;&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;b&gt;Program 11 - printf statement with format characters&lt;br /&gt;
&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;The printf function can print numbers but it requires more formatting characters in order to do it.  [What, did you actually expect C to be as easy as Qbasic? &lt;span style=&quot;font-family: Wingdings;&quot;&gt;L&lt;/span&gt;  Just wait, C++ is easier than C, I promise!]  In order to print numbers, a format specifier must be used.  This feature of the printf function will be covered later in this chapter.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;h2&gt;&lt;span xmlns=&quot;&quot;&gt;Displaying Text in C++&lt;br /&gt;
&lt;/span&gt;&lt;/h2&gt;&lt;h3&gt;&lt;span xmlns=&quot;&quot;&gt;Introduction&lt;br /&gt;
&lt;/span&gt;&lt;/h3&gt;&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;As stated earlier, the C++ language is just an advanced version of C.  This does not necessarily mean that C++ I harder to learn than C, but it mainly means that C++ has advanced features, some of which make the language easier to understand and some that make it harder to understand.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Just like C, C++ is also not a beginners language and also just like C, C++ does not have the program size limits like BASIC does. A C++ compiler must also be used to compile the C++ programs such as Visual C++, Blodshead&#39;s DevC++, or the GNU C++ compiler (Bloodshead DevC++ is included on the CD).&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;C++, like C and most other programming languages, has a minimum requirement for all of its programs.  The requirements for C++ are exactly the same as those for C.  Program 12 shows the minimum C/C++ program.  It is best to ignore what each line in Program 12 does at this time as each line will be explained later.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;table border=&quot;0&quot; style=&quot;border-collapse: collapse;&quot;&gt;&lt;colgroup&gt;&lt;col style=&quot;width: 158px;&quot;&gt;&lt;/col&gt;&lt;/colgroup&gt;&lt;tbody valign=&quot;top&quot;&gt;
&lt;tr&gt;&lt;td style=&quot;border: 0.5pt solid; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;int main( )&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;{&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    return 0;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;}&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;b&gt;Program 12 - Minimum C/C++ Program&lt;br /&gt;
&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Like C, C++ is case sensitive in both its commands as well as variables.  This means that main is not the same thing as Main or MAIN.  This is a common error for many beginning programmers.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Formatting is also fairly specific in C++.  Nearly every line in C++ will require a semicolon at the end of the line.  There are a few exceptions and these will be covered in a later chapter.  Think of the requirement of the semicolon in C++ to be like the requirement of a period at the end of a sentence in the English language.  Not all sentences in English have a period after them, some have a question mark or an exclamation mark.  For now, just follow the examples of semicolon placement.  They&#39;ll be explained soon.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;h3&gt;&lt;span xmlns=&quot;&quot;&gt;The cout Statement&lt;br /&gt;
&lt;/span&gt;&lt;/h3&gt;&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;The cout statement in C++ is similar to the Qbasic print statement and it is also similar to the C printf function.  The cout statement prints quoted text similar to the way the C printf function does in that the cout statement uses the C formatting characters for new line, tab, and so forth (see Table 5).  This is different from the Qbasic print statement as quoted text is printed exactly as is.  The cout statement does differ from the C printf function in that numbers are easily printed, just as they are in Qbasic (i.e. no special formatting characters are required) [see, told you C++ is easier than C, at least cout will let you print numbers easily &lt;span style=&quot;font-family: Wingdings;&quot;&gt;J&lt;/span&gt;].  Basically, the cout statement combines the best of C&#39;s printf function and Qbasic&#39;s print statement into one statement [kind of].&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;table border=&quot;0&quot; style=&quot;border-collapse: collapse;&quot;&gt;&lt;colgroup&gt;&lt;col style=&quot;width: 121px;&quot;&gt;&lt;/col&gt;&lt;col style=&quot;width: 113px;&quot;&gt;&lt;/col&gt;&lt;/colgroup&gt;&lt;tbody valign=&quot;top&quot;&gt;
&lt;tr&gt;&lt;td style=&quot;border: 0.5pt solid; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;b&gt;Format Character&lt;/b&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: solid solid solid none; border-width: 0.5pt 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;b&gt;Meaning in C++&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 12pt;&quot;&gt;\n&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;Insert a new line&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;\t&amp;nbsp;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;Insert a tab&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;\\&amp;nbsp;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;Print out a \&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;\&quot;&amp;nbsp;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;Print a &quot;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;b&gt;Table 5 - Cout format characters&lt;br /&gt;
&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Just like the printf function in C required the #include directive, so also does the cout statement in C++.  The cout statement is located in the iosteam.h file so the #include statement should look like &lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;#include &amp;lt;iostream.h&amp;gt;&lt;/span&gt;.  It should be noted that just because cout is a statement, C++ must still be told where to find cout.  This is because the cout statement is not part of the C++ language.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Because the cout statement is a statement and not a function, it does not require a set of parenthesis like the printf function requires, but it does require another form of punctuation known as the double less-than operator (&amp;lt;&amp;lt;).  The double less-than operator is required for each piece of data to be outputted to the screen.  For example, if the programmer wanted to print a word, then a number, and then another word using only one cout statement, then the cout would require three double less-than operators.  An example of this is shown in Program 13.  This same program can also be written by using three separate cout statements but this still requires three double less-than operators as shown in Program 14.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;table border=&quot;0&quot; style=&quot;border-collapse: collapse;&quot;&gt;&lt;colgroup&gt;&lt;col style=&quot;width: 274px;&quot;&gt;&lt;/col&gt;&lt;/colgroup&gt;&lt;tbody valign=&quot;top&quot;&gt;
&lt;tr&gt;&lt;td style=&quot;border: 0.5pt solid; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;#include &amp;lt;iostream.h&amp;gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;int main( )&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;{&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    cout&amp;lt;&amp;lt;&quot;2+2=&quot;&amp;lt;&amp;lt;4&amp;lt;&amp;lt;&quot;.&quot;;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    return 0;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;}&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;&lt;i&gt;2+2=4.&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;b&gt;Program 13 - C++ Program showing use of cout double less-than&lt;br /&gt;
&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;table border=&quot;0&quot; style=&quot;border-collapse: collapse;&quot;&gt;&lt;colgroup&gt;&lt;col style=&quot;width: 235px;&quot;&gt;&lt;/col&gt;&lt;/colgroup&gt;&lt;tbody valign=&quot;top&quot;&gt;
&lt;tr&gt;&lt;td style=&quot;border: 0.5pt solid; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;#include &amp;lt;iostream.h&amp;gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;int main( )&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;{&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    cout&amp;lt;&amp;lt;&quot;2+2=&quot;;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    cout&amp;lt;&amp;lt;4;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    cout&amp;lt;&amp;lt;&quot;.&quot;;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    return 0;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;}&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;&lt;i&gt;2+2=4.&lt;/i&gt;&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;b&gt;Program 14 - C++ Program showing use of  cout Statements&lt;br /&gt;
&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;There are two main things to notice about the cout statement.  First, if you remember the output from the Qbasic print statement, you&#39;ll remember that any non-negative numbers had a space before them.  This space is removed in C++ by using the cout statement (there is still a way to get rid of the space in Qbasic).  The second thing to notice is how everything is automatically printed on the same line as is done in C with the printf statement.  To change this, the formatting characters must be used in the printed output.  The following program demonstrates the use of the cout statement with these formatting characters.  Also, notice in the program how the letters &quot;endl&quot; (which stands for end line) can be used to simulate using &quot;\n&quot; outside of quoted text.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;table border=&quot;0&quot; style=&quot;border-collapse: collapse;&quot;&gt;&lt;colgroup&gt;&lt;col style=&quot;width: 494px;&quot;&gt;&lt;/col&gt;&lt;/colgroup&gt;&lt;tbody valign=&quot;top&quot;&gt;
&lt;tr&gt;&lt;td style=&quot;border: 0.5pt solid; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;#include &amp;lt;iostream.h&amp;gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;int main()&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;{&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;cout&amp;lt;&amp;lt;&quot;2+2=&quot;&amp;lt;&amp;lt;2+2;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;cout&amp;lt;&amp;lt;endl&amp;lt;&amp;lt;endl;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;cout&amp;lt;&amp;lt;&quot;The capital of North Carolina is&quot;;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;cout&amp;lt;&amp;lt;&quot;Raleigh\n&quot;&amp;lt;&amp;lt;&quot;with a population of&quot;;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;cout&amp;lt;&amp;lt;200000&amp;lt;&amp;lt;endl;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return 0;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;&lt;i&gt;2+2=4&lt;br /&gt;
&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;&lt;i&gt;The capital of North Carolina isRaleigh&lt;br /&gt;
&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;&lt;i&gt;with a population of200000&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;b&gt;Program 15 - C++ program showing cout statements&lt;br /&gt;
&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;h2&gt;&lt;span xmlns=&quot;&quot;&gt;Conclusion&lt;br /&gt;
&lt;/span&gt;&lt;/h2&gt;&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Each language in this chapter (Qbasic, C, and C++) has a specific statement or function to display information to the screen.  In Qbasic, the print statement is used.  In C the printf function can be used and in C++ the cout statement can be used to display information.  A comparison of the languages so far and also a comparison of the display statements is shown in Table 6.  A comparison of programs is shown in Table 7.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&lt;br /&gt;
&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;&lt;table border=&quot;0&quot; style=&quot;border-collapse: collapse;&quot;&gt;&lt;colgroup&gt;&lt;col style=&quot;width: 139px;&quot;&gt;&lt;/col&gt;&lt;col style=&quot;width: 168px;&quot;&gt;&lt;/col&gt;&lt;col style=&quot;width: 156px;&quot;&gt;&lt;/col&gt;&lt;col style=&quot;width: 127px;&quot;&gt;&lt;/col&gt;&lt;/colgroup&gt;&lt;tbody valign=&quot;top&quot;&gt;
&lt;tr&gt;&lt;td style=&quot;border: 0.5pt solid; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;b&gt;QBasic&lt;/b&gt;&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: solid solid solid none; border-width: 0.5pt 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;b&gt;C&lt;/b&gt;&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: solid solid solid none; border-width: 0.5pt 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;b&gt;C++&lt;/b&gt;&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: solid solid solid none; border-width: 0.5pt 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;b&gt;Output&lt;/b&gt;&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;PRINT &quot;Hello&quot;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;printf(&quot;Hello\n&quot;);&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;cout&amp;lt;&amp;lt;&quot;Hello\n&quot;;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;&lt;i&gt;Hello&lt;br /&gt;
&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;PRINT &quot;Hello&quot;;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;printf(&quot;Hello&quot;);&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;cout&amp;lt;&amp;lt;&quot;Hello&quot;;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;&lt;i&gt;Hello&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;PRINT 2+2;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;n/a&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;cout&amp;lt;&amp;lt;2+2;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;&lt;i&gt; 4 (in Qbasic)&lt;br /&gt;
&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;&lt;i&gt;4 (in C++)&lt;/i&gt;&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;PRINT -4;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;n/a&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;cout&amp;lt;&amp;lt;-4;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;&lt;i&gt;-4&lt;/i&gt;&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;PRINT &quot;A&quot;;&quot;B&quot;&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;printf(&quot;A&quot;);&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;printf(&quot;B&quot;);&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;printf(&quot;\n&quot;);&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;cout&amp;lt;&amp;lt;&quot;A&quot;;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;cout&amp;lt;&amp;lt;&quot;B&quot;;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;cout&amp;lt;&amp;lt;endl;&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;&lt;i&gt;AB&lt;/i&gt;&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;b&gt;Table 6 - Language Comparison&lt;br /&gt;
&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;br /&gt;
&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;table border=&quot;0&quot; style=&quot;border-collapse: collapse;&quot;&gt;&lt;colgroup&gt;&lt;col style=&quot;width: 94px;&quot;&gt;&lt;/col&gt;&lt;col style=&quot;width: 117px;&quot;&gt;&lt;/col&gt;&lt;col style=&quot;width: 174px;&quot;&gt;&lt;/col&gt;&lt;col style=&quot;width: 187px;&quot;&gt;&lt;/col&gt;&lt;/colgroup&gt;&lt;tbody valign=&quot;top&quot;&gt;
&lt;tr&gt;&lt;td style=&quot;border: 0.5pt solid; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;b&gt;Purpose&lt;/b&gt;&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: solid solid solid none; border-width: 0.5pt 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;b&gt;Qbasic&lt;/b&gt;&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: solid solid solid none; border-width: 0.5pt 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;b&gt;C&lt;/b&gt;&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: solid solid solid none; border-width: 0.5pt 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;b&gt;C++&lt;/b&gt;&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;i&gt;minimum &lt;br /&gt;
&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;i&gt;program&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;int main()&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;{&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;    return 0;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;}&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;int main()&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;{&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;    return 0;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;i&gt;program with &lt;br /&gt;
&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;i&gt;command used&lt;br /&gt;
&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;i&gt;in this chapter&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;PRINT &quot;Hello&quot;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;int main()&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;{&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;    printf(&quot;Hello\n&quot;);&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;    return 0;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;#include &amp;lt;iostream.h&amp;gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;int main()&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;{&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;    cout&amp;lt;&amp;lt;&quot;Hello&quot;&amp;lt;&amp;lt;endl;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;    return 0;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 8pt;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;b&gt;Table 7 - Program Comparison&lt;br /&gt;
&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;The print statement in Qbasic prints quoted text as is without any special formatting and can also display numbers.  It automatically prints all information on a line by itself unless told otherwise by use of the semicolon or the comma options.  The semicolon option forces the print statement to print the next piece of information on the same line while the comma option inserts a 16-space tab.  The shortcut for typing the print statement is the question mark (?).&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;In C, the printf function can print quoted information.  Special formatting codes can be inserted within the quoted text and printf will act on these formatting characters.  Printf can also display numbers but is more complicated than Qbasic&#39;s print statement.  Printf will print all information on the same line unless told otherwise by the carriage return special characters (\n).  A list of special formatting characters is shown in Table 8.  In order for printf to be used within a C program, the stdio.h file must be included.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&lt;br /&gt;
&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;table border=&quot;0&quot; style=&quot;border-collapse: collapse;&quot;&gt;&lt;colgroup&gt;&lt;col style=&quot;width: 119px;&quot;&gt;&lt;/col&gt;&lt;col style=&quot;width: 107px;&quot;&gt;&lt;/col&gt;&lt;/colgroup&gt;&lt;tbody valign=&quot;top&quot;&gt;
&lt;tr&gt;&lt;td style=&quot;border: 0.5pt solid; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;b&gt;Format Character&lt;/b&gt;&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: solid solid solid none; border-width: 0.5pt 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;b&gt;Meaning in C++&lt;/b&gt;&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 12pt;&quot;&gt;\n&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;Insert a new line&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;\t&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;Insert a tab&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;\\&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;Print out a \&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;\&quot;&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;Print a &quot;&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;b&gt;Table 8 - C/C++ Special Formatting Characters&lt;br /&gt;
&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;The cout statement in C++ is similar to the printf function as well as the print statement.  Cout will print quoted text as printf and uses the same formatting codes (see Table 8).  Cout also has the capability of printing numbers easily, as the print statement in Qbasic can do.  Similar to printf, the cout statement prints all information on the same line unless specified otherwise by the carriage return code (\n) or the end line code (endl).  In order for the cout statement to be used within a C++ program, the iostream.h file must be included.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;h2&gt;&lt;span xmlns=&quot;&quot;&gt;Problems&lt;br /&gt;
&lt;/span&gt;&lt;/h2&gt;&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[What, you thought I was going to let you get out of doing some problems?  Yeah, right! &lt;span style=&quot;font-family: Wingdings;&quot;&gt;J&lt;/span&gt;  They&#39;ll be fairly easy, I promise…at least for now &lt;span style=&quot;font-family: Wingdings;&quot;&gt;J&lt;/span&gt;]&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;Since there were three languages covered in this chapter, each of these problems should have three answers, one for each language unless otherwise specified.  Also, assume that the problem requires a complete program unless the problem states otherwise.  Also, the quotes in the problem dictate the desired output therefore do not include the quotes in the program output.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;ol style=&quot;margin-left: 54pt;&quot;&gt;&lt;span xmlns=&quot;&quot;&gt;
&lt;li&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;Write a program to print &quot;Hello&quot; on the screen on a line by itself.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;Write a program to display the sum of 4+8 on the screen in the languages that allow displaying numbers on the screen.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;Modify problem 2 to display a prompt as well as the output.  Keep the prompt and output on the same line.  [Hint:  A prompt is a description of the output, in this case the prompt is &quot;4+8=&quot;]&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;Write a program to display the numbers from 1 to 5 on the same line.  For languages that require it, insert a space between each number.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;Do problem 4 using only a single print statement or the equivalent.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;Write a program to display the numbers from 5 to 10 on the same line.  In addition, display the numbers 1 to 5 on a line by themselves and then finish the program by displaying the numbers 5 to 10 on the same line.  [Hint:  This should look similar to a box except the right side will be missing]&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;Write a program to display the numbers from 1 to 25 using a tab between each number.  Use between five and eight rows to display the numbers.&lt;/div&gt;&lt;/li&gt;
&lt;/span&gt;&lt;/ol&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://rhale78.blogspot.com/feeds/8884155680176623476/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://rhale78.blogspot.com/2010/02/intro-to-computer-programming-chapter-4.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/270091469191232126/posts/default/8884155680176623476'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/270091469191232126/posts/default/8884155680176623476'/><link rel='alternate' type='text/html' href='http://rhale78.blogspot.com/2010/02/intro-to-computer-programming-chapter-4.html' title='Intro to Computer Programming - Chapter 4: Communicating with the User'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/09185478558704427023</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-270091469191232126.post-2264616487389875611</id><published>2010-02-26T17:50:00.000-05:00</published><updated>2010-02-26T17:50:00.277-05:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Intro to Computer Programming"/><title type='text'>Intro to Computer Programming - Chapter 3: Beginning HTML</title><content type='html'>&lt;span xmlns=&quot;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;h2&gt;&lt;span xmlns=&quot;&quot;&gt;Introduction&lt;br /&gt;
&lt;/span&gt;&lt;/h2&gt;&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;One of the easier programming languages at this time is the &lt;b&gt;Hypertext Markup Language&lt;/b&gt; (&lt;b&gt;HTML&lt;/b&gt;).  HTML is usually only used for creating web pages for the Internet and it is very limited in what it can do.  Most do not really consider HTML a programming language, but rather a text formatting language.  This is partially why I&#39;m covering it first, along with it being fairly easy to learn.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Anyone can create web pages from scratch using a simple text editor such as Microsoft Windows&#39; Notepad program.  No special software is needed to create web pages.  In order to view the web page, though, a web browser such as Netscape Communicator or Microsoft Internet Explorer is needed.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;HTML has a minor problem in that each computer could display the web page slightly different.  With HTML alone there is no easy way of forcing the program to display the same on every computer.  &lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;Also another problem with HTML is that it cannot solve problems such as adding two and two together!  HTML is used to display text, tables, and pictures and also allows for &quot;links&quot; between other HTML pages but does not allow much more than that.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;h2&gt;&lt;span xmlns=&quot;&quot;&gt;Tags&lt;br /&gt;
&lt;/span&gt;&lt;/h2&gt;&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Tags are considered the commands in the HTML language.  In HTML, a tag is the symbol &quot;&amp;lt;&quot; followed by a specific command followed by &quot;&amp;gt;&quot;.  Sometimes there are beginning tags that tell HTML to start a certain command and then an ending tag to tell HTML to stop the command.  The only difference between the beginning and ending tags is that the ending tags have the symbol &quot;&amp;lt;/&quot;, the command, and then the &quot;&amp;gt;&quot;.  For example, &amp;lt;bold&amp;gt; is a starting tag to start the bold command and &amp;lt;/bold&amp;gt; is the ending command to end the bold command.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Tags in HTML as similar to certain types of punctuation in the English language.  A paragraph, for example, usually begins with an indention.  Parenthesis begin with a opening parenthesis and end with closing parenthesis.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;English has several rules that apply to punctuation.  One of them is that the latest punctuation mark that has a matching mark (parenthesis, quotes, brackets, etc), must have its closing mark before the closing mark of any other punctuation mark.  Let me explain by an example.  It would be very odd to see the following &quot; ( [ ) ] { &quot; }.  Instead, the reader would expect something like &quot; ( [ ] ) { } &quot;.  This is because the reader expects to see a closing bracket before a closing parenthesis.  The same it true with HTML and most other programming languages.  The latest starting mark must end before another ending mark of a different type.  In terms of the HTML language, the current start tag must end before another one can end, otherwise the page may not display correctly.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;h2&gt;&lt;span xmlns=&quot;&quot;&gt;HTML Programming&lt;br /&gt;
&lt;/span&gt;&lt;/h2&gt;&lt;h3&gt;&lt;span xmlns=&quot;&quot;&gt;Program Requirements&lt;br /&gt;
&lt;/span&gt;&lt;/h3&gt;&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;HTML has a few requirements for its programs.  First, the program extension must be either htm or html so the web browser can process the program correctly.  Second, the program must contain at least the start and end tags of &amp;lt;html&amp;gt; and &amp;lt;/html&amp;gt; at the beginning and end of the file.  Other than those two requirements, the programmer can use any commands or text however is required to solve the problem.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;As stated above, the minimum HTML program must contain at least the &amp;lt;html&amp;gt; and &amp;lt;/html&amp;gt; tags.  This is illustrated in Program 1.  Notice how each tag is on a separate line.  This is not a requirement for the language, but helps programmers read the program a little easier.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;br /&gt;
&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt; text-align: center;&quot;&gt;&lt;table border=&quot;0&quot; style=&quot;border-collapse: collapse;&quot;&gt;&lt;colgroup&gt;&lt;col style=&quot;width: 118px;&quot;&gt;&lt;/col&gt;&lt;/colgroup&gt;&lt;tbody valign=&quot;top&quot;&gt;
&lt;tr&gt;&lt;td style=&quot;border: 0.5pt solid; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;&amp;lt;html&amp;gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;b&gt;Program 1 - Minimum HTML Program&lt;br /&gt;
&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;h3&gt;&lt;span xmlns=&quot;&quot;&gt;Program Heading and Titles&lt;br /&gt;
&lt;/span&gt;&lt;/h3&gt;&lt;span xmlns=&quot;&quot;&gt;The heading of a HTML program contains general information about the program.  This information is usually not displayed as part of the document except in the case of the title.  The heading tags are &amp;lt;head&amp;gt; and &amp;lt;/head&amp;gt;.  The heading is usually at the very beginning of the document and does not contain many commands between the tags.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;The most common tag that is used within the head tags are the title tags &amp;lt;title&amp;gt; and &amp;lt;/title&amp;gt;.  The title of a HTML program is usually displayed at the top of the web browser as part of the browser&#39;s own title bar.  For instance, viewing the following page in Internet Explorer would make the title of Internet Explorer to become &quot;Hello – Microsoft Internet Explorer&quot;.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;table border=&quot;0&quot; style=&quot;border-collapse: collapse;&quot;&gt;&lt;colgroup&gt;&lt;col style=&quot;width: 149px;&quot;&gt;&lt;/col&gt;&lt;/colgroup&gt;&lt;tbody valign=&quot;top&quot;&gt;
&lt;tr&gt;&lt;td style=&quot;border: 0.5pt solid; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;&amp;lt;html&amp;gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;  &amp;lt;head&amp;gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    &amp;lt;title&amp;gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;      Hello&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    &amp;lt;/title&amp;gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;  &amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;b&gt;Program 2 - HTML Program Showing the Title Tag&lt;br /&gt;
&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;The heading of a HTML program is not very useful as it can not display much except for a title.  The body of a HTML program is where most of the information is contained.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;h3&gt;&lt;span xmlns=&quot;&quot;&gt;Program Body&lt;br /&gt;
&lt;/span&gt;&lt;/h3&gt;&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Just as the body of a written letter contains the content of a letter, the body of a HTML program contains all the content of the program.  To specify the body of a HTML program, use the tags &amp;lt;body&amp;gt; and &amp;lt;/body&amp;gt;.  The body of a HTML program can contain as much text or any other tags (excluding &amp;lt;html&amp;gt;, &amp;lt;head&amp;gt;, and &amp;lt;title&amp;gt;) as the programmer needs.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Any text that is within the body of the program will be displayed within the web browser as is with no formatting unless it has been modified with a tag.  Program 3 shows how the body tags are used within a program to display text within the web browser.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;br /&gt;
&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;table border=&quot;0&quot; style=&quot;border-collapse: collapse;&quot;&gt;&lt;colgroup&gt;&lt;col style=&quot;width: 552px;&quot;&gt;&lt;/col&gt;&lt;/colgroup&gt;&lt;tbody valign=&quot;top&quot;&gt;
&lt;tr&gt;&lt;td style=&quot;border: 0.5pt solid; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;&amp;lt;html&amp;gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;  &amp;lt;head&amp;gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    &amp;lt;title&amp;gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;      Hello&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    &amp;lt;/title&amp;gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;  &amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;  &amp;lt;body&amp;gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    This text will be displayed in the browser window.&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;  &amp;lt;/body&amp;gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;b&gt;Program 3 - HTML Program Showing the Body Tag&lt;br /&gt;
&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;h3&gt;&lt;span xmlns=&quot;&quot;&gt;Headings&lt;br /&gt;
&lt;/span&gt;&lt;/h3&gt;&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;The HTML language has six levels of headings that are indicated by the tags &amp;lt;h1&amp;gt;, &amp;lt;h2&amp;gt;, &amp;lt;h3&amp;gt;, &amp;lt;h4&amp;gt;, &amp;lt;h5&amp;gt;, and &amp;lt;h6&amp;gt; and each one has an associated end tag.  HTML does not force the programmer to use the headings in any particular order.  Some browsers, such as Netscape and Internet Explorer, make the text smaller as the number of the heading tag gets larger.  Program 4 demonstrates the use of the heading tags and the web browser output of the program.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;table border=&quot;0&quot; style=&quot;border-collapse: collapse;&quot;&gt;&lt;colgroup&gt;&lt;col style=&quot;width: 360px;&quot;&gt;&lt;/col&gt;&lt;/colgroup&gt;&lt;tbody valign=&quot;top&quot;&gt;
&lt;tr&gt;&lt;td style=&quot;border: 0.5pt solid; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;&amp;lt;html&amp;gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;  &amp;lt;head&amp;gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    &amp;lt;title&amp;gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;      Hello&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    &amp;lt;/title&amp;gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;  &amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;  &amp;lt;body&amp;gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    &amp;lt;h1&amp;gt;A level one heading&amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    &amp;lt;h2&amp;gt;A level two heading&amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    &amp;lt;h3&amp;gt;A level three heading&amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    &amp;lt;h4&amp;gt;A level four heading&amp;lt;/h4&amp;gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    &amp;lt;h5&amp;gt;A level five heading&amp;lt;/h5&amp;gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    &amp;lt;h6&amp;gt;A level six heading&amp;lt;/h6&amp;gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;  &amp;lt;/body&amp;gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;h1&gt;A level one heading &lt;br /&gt;
&lt;/h1&gt;&lt;h2&gt;A level two heading &lt;br /&gt;
&lt;/h2&gt;&lt;h3&gt;A level three heading &lt;br /&gt;
&lt;/h3&gt;&lt;h4&gt;A level four heading &lt;br /&gt;
&lt;/h4&gt;&lt;h5&gt;A level five heading &lt;br /&gt;
&lt;/h5&gt;&lt;h6&gt;A level six heading &lt;/h6&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;b&gt;Program 4 - HTML Program Showing Heading Tags and Associated Output&lt;br /&gt;
&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;h3&gt;&lt;span xmlns=&quot;&quot;&gt;Paragraphs, Line Breaks, and Preformatted Text&lt;br /&gt;
&lt;/span&gt;&lt;/h3&gt;&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Text within HTML programs is automatically flowed together until something forces it to being a new paragraph.  Two of the ways to force text to break are the paragraph (&amp;lt;p&amp;gt;) and line break (&amp;lt;br&amp;gt;) tags.  Another way to force text to be exactly the way the programmer intended is to use the preformatted tag (&amp;lt;pre&amp;gt; and &amp;lt;/pre&amp;gt;).  Program 5 demonstrates the use of all three of these tags.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;The paragraph tag is used to indicate the start of a new paragraph.  Most browsers add a blank line when encountering the paragraph tag.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;The line break tag causes the current line to break, similar to the paragraph tag, but does not insert a blank line between the test before the tag and the text after the tag.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;The preformatted tag forces the browser to display the text exactly as it was entered in the program.  In this format, spaces and line breaks are preserved and the text is not automatically flowed together as normally.  Notice that this tag also has an associated end tag.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;table border=&quot;0&quot; style=&quot;border-collapse: collapse;&quot;&gt;&lt;colgroup&gt;&lt;col style=&quot;width: 638px;&quot;&gt;&lt;/col&gt;&lt;/colgroup&gt;&lt;tbody valign=&quot;top&quot;&gt;
&lt;tr&gt;&lt;td style=&quot;border: 0.5pt solid; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;&amp;lt;html&amp;gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;  &amp;lt;head&amp;gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    &amp;lt;title&amp;gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;      Beginning HTML&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    &amp;lt;/title&amp;gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;  &amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;  &amp;lt;body&amp;gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    The paragraph tag is used to indicate the &lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    start of a new paragraph.  Most browsers &lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    add a blank line when encountering the paragraph&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    tag.&amp;lt;p&amp;gt;The line break tag causes the current&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    line to break,&amp;lt;br&amp;gt; similar to the paragraph tag,&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    &amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    but does not insert a blank line between the&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    test before the tag and the text after the &lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    tag.  The preformatted tag forces...&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;    &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;  &amp;lt;/body&amp;gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;The paragraph tag is used to indicate the start of a new paragraph. Most browsers add a blank line when encountering the paragraph tag. &lt;br /&gt;
&lt;br /&gt;
The line break tag causes the current line to break,&lt;br /&gt;
similar to the paragraph tag, &lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;/div&gt;&lt;pre&gt;&lt;code&gt;    but does not insert a blank line between the
&lt;/code&gt;&lt;/pre&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;/div&gt;&lt;pre&gt;&lt;code&gt;    test before the tag and the text after the 
&lt;/code&gt;&lt;/pre&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;/div&gt;&lt;pre&gt;&lt;code&gt;    tag.  The preformatted tag forces...&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;b&gt;Program 5 - HTML Program Showing Paragraph and line breaks and Preformatted output&lt;br /&gt;
&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;h3&gt;&lt;span xmlns=&quot;&quot;&gt;Text Formatting&lt;br /&gt;
&lt;/span&gt;&lt;/h3&gt;&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;The HTML language has several tags that allow the programmer to format specific sections of text.  The type of formatting that is allowed by HTML is similar to the formatting options supported by modern day word processors.  This includes bold (&amp;lt;b&amp;gt;), italic (&amp;lt;i&amp;gt;), and underline (&amp;lt;u&amp;gt;).  Each of these tags also have an associated end tag.  These tags can also be combined to produce formats such as bold italic (&amp;lt;b&amp;gt;&amp;lt;i&amp;gt;).&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;HTML also allows the programmer to center text or images by using the center tag (&amp;lt;center&amp;gt; and &amp;lt;/center&amp;gt;).&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;h3&gt;&lt;span xmlns=&quot;&quot;&gt;Images&lt;br /&gt;
&lt;/span&gt;&lt;/h3&gt;&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;It is common for programmers to include images and pictures in their HTML programs to display a concept to a viewer of their web pages.  The image (&amp;lt;img src&amp;gt;) tag is used for this purpose.  The image can be either of GIF or JPG format and are displayed along with the text.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;The image tag is slightly different from the other tags in that it requires more information along within the tag.  This tag requires at least the filename and web address of the image to be included.  For example, to include an image called &quot;bird.jpg&quot; into the web page, the image tag would be &lt;span style=&quot;font-family: Courier New;&quot;&gt;&amp;lt;img src=&quot;bird.jpg&quot;&amp;gt;.&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;h3&gt;&lt;span xmlns=&quot;&quot;&gt;Horizontal Lines&lt;br /&gt;
&lt;/span&gt;&lt;/h3&gt;&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Sometimes the programmer wishes to separate one section of a page from another.  One of the more common ways of doing this is to use a horizontal line to separate the sections.  The tag to draw a horizontal line is &amp;lt;hr&amp;gt;.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;h3&gt;&lt;span xmlns=&quot;&quot;&gt;Hypertext Links&lt;br /&gt;
&lt;/span&gt;&lt;/h3&gt;&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;One of the most common tags in the HTML language is the hypertext link tag (&amp;lt;a href&amp;gt; and &amp;lt;/a&amp;gt;).  This tag allows the viewer of the web page to link to another document.  This &quot;other document&quot; can be another web page, an image or movie, or even a sound.  &lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;The hyperlink tag is similar to the image tag in that it requires other information in order to work correctly.  The information this tag requires is the web address (URL) and/or filename of the document to be linked to.  The tag also allows a text description of what the link goes to.  The next program will demonstrate the hypertext link as well as the other features of the HTML language covered so far.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;table border=&quot;0&quot; style=&quot;border-collapse: collapse;&quot;&gt;&lt;colgroup&gt;&lt;col style=&quot;width: 638px;&quot;&gt;&lt;/col&gt;&lt;/colgroup&gt;&lt;tbody valign=&quot;top&quot;&gt;
&lt;tr&gt;&lt;td style=&quot;border: 0.5pt solid; padding-left: 7px; padding-right: 7px;&quot;&gt;&amp;lt;html&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;title&amp;gt;&lt;br /&gt;
&lt;br /&gt;
My Web Page&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/title&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;body&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;h1&amp;gt;Favorite Web Sites&amp;lt;/h1&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;a href=&quot;http://www.microsoft.com&quot;&amp;gt;Microsoft Corp&amp;lt;/a&amp;gt;&amp;lt;p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;a href=&quot;http://www.intellicast.com&quot;&amp;gt;Intellicast Weather&amp;lt;/a&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;h2&amp;gt;ECU&#39;s Todd Dining Hall&amp;lt;/h2&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;img src=&quot;http://www.ecu.edu/images/horiz_l/todd_day.jpg&quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Microsoft&amp;lt;/b&amp;gt;, &amp;lt;b&amp;gt;Intellicast&amp;lt;/b&amp;gt;, and &amp;lt;b&amp;gt;ECU&amp;lt;/b&amp;gt; are &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;&amp;lt;i&amp;gt;&amp;lt;u&amp;gt;not&amp;lt;/u&amp;gt;&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt; responsible for the contents of this web page&lt;br /&gt;
&lt;br /&gt;
and are &amp;lt;b&amp;gt;only&amp;lt;/b&amp;gt; used as examples of how HTML tags can be used.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/body&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;/div&gt;&lt;h1&gt;Favorite Web Sites&lt;br /&gt;
&lt;/h1&gt;&lt;a href=&quot;http://www.microsoft.com/&quot;&gt;Microsoft Corp&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://www.intellicast.com/&quot;&gt;Intellicast Weather&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;/div&gt;&lt;h2&gt;ECU&#39;s Todd Dining Hall&lt;br /&gt;
&lt;/h2&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Microsoft&lt;/b&gt;, &lt;b&gt;Intellicast&lt;/b&gt;, and &lt;b&gt;ECU&lt;/b&gt; are &lt;span style=&quot;text-decoration: underline;&quot;&gt;&lt;b&gt;&lt;i&gt;not&lt;/i&gt;&lt;/b&gt;&lt;/span&gt; responsible for the contents of this web page and are &lt;b&gt;only&lt;/b&gt; used as examples of how HTML tags can be used.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;b&gt;Program 6 - Final HTML Program&lt;br /&gt;
&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;h3&gt;&lt;span xmlns=&quot;&quot;&gt;Other Tags&lt;br /&gt;
&lt;/span&gt;&lt;/h3&gt;&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;The HTML language is not a complex language but it is fairly large and it is still evolving.  If you wish to learn more about HTML, the web is the best place to learn about the language.  There are also some good books available that cover the language more in depth.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://rhale78.blogspot.com/feeds/2264616487389875611/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://rhale78.blogspot.com/2010/02/intro-to-computer-programming-chapter-3.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/270091469191232126/posts/default/2264616487389875611'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/270091469191232126/posts/default/2264616487389875611'/><link rel='alternate' type='text/html' href='http://rhale78.blogspot.com/2010/02/intro-to-computer-programming-chapter-3.html' title='Intro to Computer Programming - Chapter 3: Beginning HTML'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/09185478558704427023</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-270091469191232126.post-2879390129142092567</id><published>2010-02-26T17:49:00.000-05:00</published><updated>2010-02-26T17:49:00.234-05:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Intro to Computer Programming"/><title type='text'>Intro to Computer Programming – Chapter 2: Basic Computer Terminology</title><content type='html'>&lt;span xmlns=&quot;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;h1&gt;&lt;span xmlns=&quot;&quot;&gt;Chapter 2: Basic Computer Terminology&lt;br /&gt;
&lt;/span&gt;&lt;/h1&gt;&lt;h2&gt;&lt;span xmlns=&quot;&quot;&gt;Introduction&lt;br /&gt;
&lt;/span&gt;&lt;/h2&gt;&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;As stated earlier, computers have added many new terms to the English language.  More specifically, programming languages have also added many terms to the language or have added new definitions to their meanings.  Before going into different programming languages, there are a few terms that must be understood that are common to most all computer languages.  The programmer should realize that most of these terms are related to math in some form as computers are based solely on math, more specifically binary math.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;h2&gt;&lt;span xmlns=&quot;&quot;&gt;The Binary Number System&lt;br /&gt;
&lt;/span&gt;&lt;/h2&gt;&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Computers are based solely on math.  Due to how computers are produced, they can only really deal with two numbers, 0 and 1.  This style of numbering is called the binary number system (in math terms it is considered base-two).  An individual digit of a binary number is called a&lt;b&gt; bit (a bit is the smallest number a computer can deal with)&lt;/b&gt;.  Before explaining binary, I&#39;ll explain how humans deal with numbers.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Humans normally deal with the decimal number system (in math the decimal system is considered to be base-ten).  The decimal number system has ten numbers in it, 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9.  The way we use this numbering system is we look at the rightmost digit and count to the left.  For instance, if there are 4 digits (1000 for example), then the number must be in the thousands and that number must be somewhere between 1,000 and 9,999.  We were taught in elementary school that the rightmost digit is the ones position, the one to the left is the tens position, and so forth.  What is actually happening is we are calculating higher powers of 10 (the base according to mathematicians) as we go to the left.  If you&#39;re confused, just bare with me and let me explain and show you how this works.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;The rightmost digit corresponds to 10&lt;sup&gt;0&lt;/sup&gt; which is equal to 1 (any number to a zero power is equal to one [don&#39;t ask me why, just trust me and remember it &lt;span style=&quot;font-family: Wingdings;&quot;&gt;J&lt;/span&gt;]).  The digit to the left of that one is equal to 10&lt;sup&gt;1&lt;/sup&gt; which equals 10.  The next one is equal to 10&lt;sup&gt;2&lt;/sup&gt; (10x10) which is equal to 100.  The forth digit from the right is equal to 10&lt;sup&gt;3&lt;/sup&gt; (10x10x10) which is 1,000.  See Table 2 to see how the decimal system calculates one million.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;table border=&quot;0&quot; style=&quot;border-collapse: collapse;&quot;&gt;&lt;colgroup&gt;&lt;col style=&quot;width: 47px;&quot;&gt;&lt;/col&gt;&lt;col style=&quot;width: 47px;&quot;&gt;&lt;/col&gt;&lt;col style=&quot;width: 47px;&quot;&gt;&lt;/col&gt;&lt;col style=&quot;width: 47px;&quot;&gt;&lt;/col&gt;&lt;col style=&quot;width: 47px;&quot;&gt;&lt;/col&gt;&lt;col style=&quot;width: 47px;&quot;&gt;&lt;/col&gt;&lt;col style=&quot;width: 47px;&quot;&gt;&lt;/col&gt;&lt;/colgroup&gt;&lt;tbody valign=&quot;top&quot;&gt;
&lt;tr style=&quot;height: 82px;&quot;&gt;&lt;td colspan=&quot;2&quot; style=&quot;border: 0.5pt solid; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 5pt;&quot;&gt;1,000,000&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; style=&quot;border-color: -moz-use-text-color; border-style: solid solid solid none; border-width: 0.5pt 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 5pt;&quot;&gt;100,000&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; style=&quot;border-color: -moz-use-text-color; border-style: solid solid solid none; border-width: 0.5pt 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 5pt;&quot;&gt;10,000&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: solid solid solid none; border-width: 0.5pt 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 5pt;&quot;&gt;1,000&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: solid solid solid none; border-width: 0.5pt 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 5pt;&quot;&gt;100&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: solid solid solid none; border-width: 0.5pt 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 5pt;&quot;&gt;10&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: solid solid solid none; border-width: 0.5pt 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 5pt;&quot;&gt;1&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style=&quot;height: 47px;&quot;&gt;&lt;td colspan=&quot;2&quot; style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 5pt;&quot;&gt;10&lt;sup&gt;6&lt;/sup&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 5pt;&quot;&gt;10&lt;sup&gt;5&lt;/sup&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 5pt;&quot;&gt;10&lt;sup&gt;4&lt;/sup&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 5pt;&quot;&gt;10&lt;sup&gt;3&lt;/sup&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 5pt;&quot;&gt;10&lt;sup&gt;2&lt;/sup&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 5pt;&quot;&gt;10&lt;sup&gt;1&lt;/sup&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 5pt;&quot;&gt;10&lt;sup&gt;0&lt;/sup&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;1&amp;nbsp;&lt;/td&gt;&lt;td colspan=&quot;2&quot; style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;, 0&amp;nbsp;&lt;/td&gt;&lt;td colspan=&quot;2&quot; style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;0&amp;nbsp;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;0&amp;nbsp;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;, 0&amp;nbsp;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;0&amp;nbsp;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;0&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;b&gt;Table 2 - Powers of 10&lt;br /&gt;
&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Notice that so far we have only calculated a number that has a one as the leftmost digit and all other digits are zero.  This is basic to understanding how humans figure out what a number is.  The next step is to show how we calculate any number.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;A simple formula is needed in order to calculate the value of any number of the decimal system.  Since there are ten numbers in the decimal system and since the number modifies the value at its position (a 40 is not a 10, but is 4 times 10), we must find a way to find out what the actual value is at a specific position.  All we have to do is multiply the digit at a certain position with its power and add all of these numbers together.  For example, the number 423 is equal to 3*10&lt;sup&gt;0 &lt;/sup&gt;+ 2*10&lt;sup&gt;1&lt;/sup&gt; + 4*10&lt;sup&gt;2&lt;/sup&gt; which is equal to 3*1 + 2*10 + 4*100 which is equal to 423 [of course].  Have I thoroughly confused you?  Hope not.  This process of breaking apart a number is actually considered to be converting a decimal number to a decimal number, which is useful as an example but nothing more.  What we would like to do is see how the binary number system works in comparison to the decimal number system.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;The binary number system is very similar to the decimal number system except that we use two to a certain power instead of ten.  The formula is the same.  It is useful to note that the formula will convert a binary number into a decimal number.  Table 3 shows how a binary number is converted into a decimal number.  Note how the binary number only has the digits 0 or 1, that&#39;s because that is all the binary number system contains.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&lt;br /&gt;
&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;table border=&quot;0&quot; style=&quot;border-collapse: collapse;&quot;&gt;&lt;colgroup&gt;&lt;col style=&quot;width: 47px;&quot;&gt;&lt;/col&gt;&lt;col style=&quot;width: 47px;&quot;&gt;&lt;/col&gt;&lt;col style=&quot;width: 47px;&quot;&gt;&lt;/col&gt;&lt;col style=&quot;width: 47px;&quot;&gt;&lt;/col&gt;&lt;col style=&quot;width: 47px;&quot;&gt;&lt;/col&gt;&lt;col style=&quot;width: 47px;&quot;&gt;&lt;/col&gt;&lt;col style=&quot;width: 47px;&quot;&gt;&lt;/col&gt;&lt;col style=&quot;width: 47px;&quot;&gt;&lt;/col&gt;&lt;/colgroup&gt;&lt;tbody valign=&quot;top&quot;&gt;
&lt;tr style=&quot;height: 41px;&quot;&gt;&lt;td colspan=&quot;2&quot; style=&quot;border: 0.5pt solid; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 5pt;&quot;&gt;128&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; style=&quot;border-color: -moz-use-text-color; border-style: solid solid solid none; border-width: 0.5pt 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 5pt;&quot;&gt;64&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; style=&quot;border-color: -moz-use-text-color; border-style: solid solid solid none; border-width: 0.5pt 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 5pt;&quot;&gt;32&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; style=&quot;border-color: -moz-use-text-color; border-style: solid solid solid none; border-width: 0.5pt 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 5pt;&quot;&gt;16&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: solid solid solid none; border-width: 0.5pt 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 5pt;&quot;&gt;8&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: solid solid solid none; border-width: 0.5pt 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 5pt;&quot;&gt;4&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: solid solid solid none; border-width: 0.5pt 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 5pt;&quot;&gt;2&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: solid solid solid none; border-width: 0.5pt 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 5pt;&quot;&gt;1&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style=&quot;height: 35px;&quot;&gt;&lt;td colspan=&quot;2&quot; style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 5pt;&quot;&gt;2&lt;sup&gt;7&lt;/sup&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 5pt;&quot;&gt;2&lt;sup&gt;6&lt;/sup&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 5pt;&quot;&gt;2&lt;sup&gt;5&lt;/sup&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 5pt;&quot;&gt;2&lt;sup&gt;4&lt;/sup&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 5pt;&quot;&gt;2&lt;sup&gt;3&lt;/sup&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 5pt;&quot;&gt;2&lt;sup&gt;2&lt;/sup&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 5pt;&quot;&gt;2&lt;sup&gt;1&lt;/sup&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 5pt;&quot;&gt;2&lt;sup&gt;0&lt;/sup&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style=&quot;height: 5px;&quot;&gt;&lt;td colspan=&quot;2&quot; style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;1&amp;nbsp;&lt;/td&gt;&lt;td colspan=&quot;2&quot; style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;1&amp;nbsp;&lt;/td&gt;&lt;td colspan=&quot;2&quot; style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;0&amp;nbsp;&lt;/td&gt;&lt;td colspan=&quot;2&quot; style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;1&amp;nbsp;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;0&amp;nbsp;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;0&amp;nbsp;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;1&amp;nbsp;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;0&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style=&quot;height: 5px;&quot;&gt;&lt;td colspan=&quot;8&quot; style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: center;&quot;&gt;11010010 in binary =&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;0*2&lt;sup&gt;0&lt;/sup&gt; + 1*2&lt;sup&gt;1&lt;/sup&gt; + 0*2&lt;sup&gt;2&lt;/sup&gt; + 0*2&lt;sup&gt;3&lt;/sup&gt; + 1*2&lt;sup&gt;4&lt;/sup&gt; + 0*2&lt;sup&gt;5&lt;/sup&gt; + 1*2&lt;sup&gt;6&lt;/sup&gt; + 1*2&lt;sup&gt;7&lt;/sup&gt; =&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;0 + 2 + 0 + 0 + 16 + 64 + 128 =&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;210 in decimal&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;b&gt;Table 3 - Binary to Decimal&lt;br /&gt;
&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Computers themselves use binary but programmers use decimal, octal (base-eight [contains only the numbers 0-7]), and hexadecimal (base-sixteen [contains the numbers 0-9 as well as the letters A-F]).  It is not necessary that the programmer learn these other bases at this time but just be aware that they exist in the computer field (you&#39;ll see hexadecimal [short form is hex] soon).&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;h2&gt;&lt;span xmlns=&quot;&quot;&gt;Types of Numbers&lt;br /&gt;
&lt;/span&gt;&lt;/h2&gt;&lt;span xmlns=&quot;&quot;&gt;Humans have various terms to refer to certain types of numbers.  For instance, we call ½ a fraction, and .4 a decimal, and –4 a negative number.  For more complex math, we call 5&lt;i&gt;i&lt;/i&gt;+3 a complex number.  Computers have similar names for numbers.  All of the following number types can be signed (allowing positive, zero, and negative numbers) or unsigned (allowing only zero or positive numbers).  A special note is that on numbers above 999, a comma should not be included within the number.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;h3&gt;&lt;span xmlns=&quot;&quot;&gt;Integers&lt;br /&gt;
&lt;/span&gt;&lt;/h3&gt;&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Integers are numbers without any decimal points.  The number can be negative, zero, or positive.  It must be a whole number and not contain a fraction.  For example,  1000, 0, 25, 1, -4 are all integers but .1, .333, 5.2, 1.000001, and –99.99 are not integers.  &lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;Integers are used in computers for speed as the computer does not have to deal with fractions.  Some examples of how they are used in computers would be in the form of a date (1-1-2001) or time (12:00).&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;On most computers, integers are measured in how many bits (binary digits) they contain.  On old computers, an integer contained only 8 bits.  On modern computers, an integer contains anywhere between 32 and 128 bits [depends on the computer].  What this means is that a computer can only count but so high or low.  An 8-bit number has a decimal range from 0 to 255 or –127 to 128 [if you&#39;re wondering how I&#39;m getting the decimal ranges, 2&lt;sup&gt;8&lt;/sup&gt;=256 numbers.  Zero must be included so the range is 0 to 255.].  A 16-bit number has a maximum range up to 65,536 numbers.  A 32-bit number has an upper limit of 4,294,967,296!  You may ask what happens when you try to go over this range, well, it depends.  If the computer is allowed to use negative numbers as well as positive then if you add 1 to a number that has reached the maximum limit, you&#39;ll get a negative number on the lower limit of the range.  On the other hand, if the computer is not allowed to use negative numbers but only positive ones and you add a 1 to a number already at its maximum, you&#39;ll get zero as the answer.  Yes, this can cause problems.  (ah, another problem for you to solve in the future &lt;span style=&quot;font-family: Wingdings;&quot;&gt;J&lt;/span&gt;).&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;h3&gt;&lt;span xmlns=&quot;&quot;&gt;Byte&lt;br /&gt;
&lt;/span&gt;&lt;/h3&gt;&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;A byte is a smaller version of an integer.  It is usually only 8-bits long.  As stated earlier, it contains 256 numbers.  Bytes are used mainly for characters that the computer can produce.  I&#39;ll explain this at a later time.  For now, just think of a byte as a smaller version of an integer.  Believe it or not, it is usually faster to use integers instead of bytes for storing information!  Yes, bytes are much smaller than integers, but the computer&#39;s basic unit is an integer.  [It is similar to how an American&#39;s basic unit of money is the dollar but we have smaller units of money such as quarters and pennies].&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;h3&gt;&lt;span xmlns=&quot;&quot;&gt;Single and Double Precision and Floats&lt;br /&gt;
&lt;/span&gt;&lt;/h3&gt;&lt;span xmlns=&quot;&quot;&gt;Numbers that contain decimals are called, depending on the programming language, single/double precision or floats.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;The reason for the single and double precision difference is just the bit size and the number of digits that could be in the number.  For example, a single precision number may store the fraction 1/3 as 0.33333 where a double precision will store it as 0.3333333333.  Double precision does not necessarily mean that there will be double the amount of digits available for a number, this will depend on the language being used.  Another note, single precision numbers can be calculated faster than double precision numbers, but both are much slower than integers.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;Floats (named floats for the term floating point) are single or double precision numbers with just a different name.  They are called floats because the decimal point can &quot;float&quot; anywhere within the number.  I will refer to this group of numbers as floats throughout this book except when talking about certain languages.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;This group of numbers is useful for calculating formulas that contain fractions.  For example, to calculate how much tax would be added to an item would require a float.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;h3&gt;&lt;span xmlns=&quot;&quot;&gt;Longs&lt;br /&gt;
&lt;/span&gt;&lt;/h3&gt;&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Longs are basically integers that have a larger range than a normal integer.  Longs are useful when an integer is just too small.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;h2&gt;&lt;span xmlns=&quot;&quot;&gt;Other Types&lt;br /&gt;
&lt;/span&gt;&lt;/h2&gt;&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Computers can deal with other types of information as well as numbers.  To be truthful, even these types are numbers but they are in a special classification because of the way humans perceive them.  For instance, if a statement is true, a human probably wouldn&#39;t say that a statement was –1.  In Qbasic this is what the computer would say to a true statement!  For example, the formula 2+2=4.  A human would say, yes, 2+2 does equal 4.  In Qbasic, the computer would say 2+2=4 equals –1!&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;h3&gt;&lt;span xmlns=&quot;&quot;&gt;Boolean&lt;br /&gt;
&lt;/span&gt;&lt;/h3&gt;&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Boolean types deal with a section of mathematics called Boolean logic.  To put this in simple terms, it deals with whether a statement is true or false.  The computer has no idea what true means or what false means but uses Boolean logic to figure out the truth of a statement.  In most programming languages, 1 means true and 0 means false (Qbasic uses –1 to mean true and 0 to mean false).&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;h3&gt;&lt;span xmlns=&quot;&quot;&gt;Character&lt;br /&gt;
&lt;/span&gt;&lt;/h3&gt;&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;A character is almost always the same thing as a byte.  A character can be any single letter, number, or symbol that is on the keyboard, among others symbols that the computer can produce.  A character is actually the symbol itself (such as an &#39;A&#39; or space).  Internally the computer represents each symbol as a number.  For instance, the character &#39;A&#39; is internally represented as the number 65 and a space as number 32.  Where does the computer get these numbers from for the characters?&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;Around 1968, a group of computer scientists came up with a table that contains all of the symbols the computer can normally produce and assigned a number to each of them.  This table is called the &lt;b&gt;ASCII &lt;/b&gt;table&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;[&lt;b&gt;American Standard Code for Information Interchange&lt;/b&gt;].  This table contains 256 individual characters.  The first half of the ASCII table is standard for all modern day personal computers.  Figure 1 shows the entire IBM PC version of the ASCII table.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;span style=&quot;font-family: Arial;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;b&gt;Figure 1 – Hex IBM PC ASCII Table&lt;br /&gt;
&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span xmlns=&quot;&quot;&gt;In the programming language Java, the ASCII table is being replaced with a table called Unicode.  The Unicode table contains the ASCII table as well as many more symbols.  It uses a 16-bit byte value and thus has a total capacity of 65,536 symbols.  &lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;h3&gt;&lt;span xmlns=&quot;&quot;&gt;Strings&lt;br /&gt;
&lt;/span&gt;&lt;/h3&gt;&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Another useful type is the string.  Strings are just a bunch of characters &quot;strung&quot; together.  For instance, a single word or part of a word is a string or even an entire sentence or paragraph could be considered a string.  Strings are almost always enclosed in quotes in programming languages.  Since numbers are considered to also be characters (numbers are included in the ASCII table so they can be a character), a series of numbers could be considered a string.  What makes the difference between a number and a string?  The quotes.  For instance, 123 is an integer, but &quot;123&quot; is a string that contains the characters &quot;1&quot;, &quot;2&quot;, and &quot;3&quot;.  Strings are useful in storing things such as names, words, addresses, and so forth.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;h3&gt;&lt;span xmlns=&quot;&quot;&gt;Others&lt;br /&gt;
&lt;/span&gt;&lt;/h3&gt;&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Each programming language has different types to represent certain types of information.  Some types are difficult to explain until some information is known about the language itself.  I&#39;ll explain these other types when they are useful to learning about a particular language.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://rhale78.blogspot.com/feeds/2879390129142092567/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://rhale78.blogspot.com/2010/02/intro-to-computer-programming-chapter-2.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/270091469191232126/posts/default/2879390129142092567'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/270091469191232126/posts/default/2879390129142092567'/><link rel='alternate' type='text/html' href='http://rhale78.blogspot.com/2010/02/intro-to-computer-programming-chapter-2.html' title='Intro to Computer Programming – Chapter 2: Basic Computer Terminology'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/09185478558704427023</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-270091469191232126.post-6534933279530742969</id><published>2010-02-26T17:48:00.000-05:00</published><updated>2010-02-26T17:48:00.199-05:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Intro to Computer Programming"/><title type='text'>Intro to Computer Programming – Chapter 1: Problem Solving</title><content type='html'>&lt;span xmlns=&quot;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;h1&gt;&lt;span xmlns=&quot;&quot;&gt;Chapter 1:  Problem Solving&lt;br /&gt;
&lt;/span&gt;&lt;/h1&gt;&lt;h2&gt;&lt;span xmlns=&quot;&quot;&gt;Introduction&lt;br /&gt;
&lt;/span&gt;&lt;/h2&gt;&lt;span xmlns=&quot;&quot;&gt;In order to write a program for a computer, the programmer must know what the program is going to do, how it will do it, and what it the input and output of the program will be.  In order to do this, the programmer must have problem solving skills.  For simple programs, the programmer will just need basic problem solving skills.  These problem solving skills will improve as the programmer gains experience in programming.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;A programmer could come against a problem as simple as how to display a letter on the screen to something as complex as making a robot walk across a room or flying the space shuttle.  Displaying a letter on the screen is very easy in most languages and can be solved by all programmers, as long as the programmer knows the basic commands of the language.  Flying the space shuttle is a slightly different story.  It takes a team of NASA programmers many months to solve the complex problems that are encountered by flying the space shuttle.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;The beginner programmer must also realize that there is usually more than one way to solve a particular problem.  For instance, there are at least five ways to write a letter on the screen in the language Qbasic; which way the programmer chooses to display a letter on the screen would depend upon the specifics of the problem or even the personal preferences of the programmer.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;h2&gt;&lt;span xmlns=&quot;&quot;&gt;How to Solve Problems&lt;br /&gt;
&lt;/span&gt;&lt;/h2&gt;&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;There are many ways to solve problems.  A problem can usually be solved if enough information is known about the problem.  If a person is given a problem that requires a specific answer, the programmer must know how to get the required information from the problem in order to get an answer.  It is similar to driving from one location to another.  The person must know where to start and where to finish, and any places to visit on the trip.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Let&#39;s take the problem of taking a trip from Florida to New York.  A person who wishes to solve this problem must know first exactly where they are in Florida and where in New York they wish to visit.  Next, they need to know what means of travel they will take (can they walk, drive, fly, take a boat, etc).  They will also need to know where they wish to stop while traveling to New York.  Some other things to consider are how long they wish to be traveling, how much money they have for the trip, and possibly how much luggage they wish to take.  All or most of these questions must be answered before the trip should ever take place and then when certain questions are answered (such as means of travel), it could bring up more questions as which direction to travel or which roads to travel.  As with most problems, there are many ways to travel from Florida to New York.  The same is true with computer programming.  Sometimes there are restrictions on the problem, such as taking the shortest route from Florida to New York, which could restrict the number of answers down to a few.  This is also true with computer programming.  As the traveler gains experience, they will know the best way to travel from Florida to New York and will also know the best places to stop on the way.  Computer programmers also gain experience as they solve computer related problems.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;There is no set way to solve a given computer problem.  Each problem is different and therefore requires a different way to find a solution.  Here are a few guidelines that a programmer should go through for each problem.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;ol&gt;&lt;span xmlns=&quot;&quot;&gt;
&lt;li&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;Read.  Most of the time important information is enclosed in the description of the problem.  The problem should be read until the programmer understands what is requested.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;Understand.  The programmer must be able to understand the problem completely before telling the computer how to solve the problem.  The programmer must be able to put the solution in a very specific series of steps so the computer can produce the desired answer.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;Ask.  If not enough information is given in the description of the problem, ask questions to someone who may know how to solve the problem or to the person who produced the problem.  Two heads are almost always better than one!  Books and the Internet are also useful resources if another person is not available.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;Think.  Think of how a simpler problem could be applied to help solve this problem.  Most of the time a harder problem is just a collection of simpler problems.  For example, multi-digit multiplication contains simpler problems such as single-digit multiplication as well as addition.  It is not always possible to come up with an easy solution to a problem.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;Solve.  If the programmer can produce a solution by hand, then a program can be more easily produced.  If the programmer has no idea how to solve the problem, how will the programmer be able to tell the computer how to solve it?&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;Choose.  Choose the language that best helps solve the problem or use the language the programmer already knows.  If the programmer only knows Fortran, but the best language to use is Cobol, then the programmer should attempt (not all problems can be solved in every language) to produce the solution in Fortran, unless the programmer wishes to learn Cobol.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;Code.  Produce the program in the chosen language and make sure it is free from errors.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;Test.  Make sure the program produces the correct answers, if not, the problem should be thought through more carefully and redone.  The reason to solve the problem was to get the correct answer, not incorrect answers.&lt;/div&gt;&lt;/li&gt;
&lt;/span&gt;&lt;/ol&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://rhale78.blogspot.com/feeds/6534933279530742969/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://rhale78.blogspot.com/2010/02/intro-to-computer-programming-chapter-1.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/270091469191232126/posts/default/6534933279530742969'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/270091469191232126/posts/default/6534933279530742969'/><link rel='alternate' type='text/html' href='http://rhale78.blogspot.com/2010/02/intro-to-computer-programming-chapter-1.html' title='Intro to Computer Programming – Chapter 1: Problem Solving'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/09185478558704427023</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-270091469191232126.post-5083353388789518281</id><published>2010-02-26T17:47:00.001-05:00</published><updated>2010-02-26T17:47:00.186-05:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Intro to Computer Programming"/><title type='text'>Intro to Computer Science – Preface</title><content type='html'>&lt;span xmlns=&quot;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;h1&gt;&lt;span xmlns=&quot;&quot;&gt;Preface&lt;br /&gt;
&lt;/span&gt;&lt;/h1&gt;&lt;h2&gt;&lt;span xmlns=&quot;&quot;&gt;What this book is about&lt;br /&gt;
&lt;/span&gt;&lt;/h2&gt;&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;In today&#39;s information age, computers are all around us.  Computers are in our vehicles, in our televisions, our microwaves, our telephones, and countless other devices we use daily.  One question to think about is how do these computers know what to do?  They are just made out of silicon [i.e. sand], metal, carbon, and a few other elements.  The truth is, they don&#39;t know what to do.  They have to be told what to do and how to do it and the only way to do that is to give them instructions on how to do something.  The instructions to do a particular task for computers are collectively called a program.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Each different type of computer can possibly have different sets of instructions that it understands.  These sets of instructions are called a programming language.  A programming language can be thought of like a human spoken or written language.  English, for example, has different words in it than a language such as French.  They possibly have the same words in both, and the words could mean the same or they could mean something completely different.  A person can know only English, or only French, or a person could know both of them.  The same is true with computers.  A computer could understand languages such as Assembly, C, Java, Pascal, or Basic (think of these like they are human languages that you&#39;ve never heard of).&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Just as human languages come from different families of languages, such as French and German are of the Romantic language family, the same is true with computer languages.  For example, under the C family of computer languages are programming languages such as C, C++, C# [pronounced C sharp], and Java.  Under the Basic family are languages such as BASIC, BASICA, Qbasic, QuickBasic, and Visual Basic.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Some human languages are not used anymore, except for very special purposes.  Examples of these languages are Egyptian, Ancient Greek, and Ancient Hebrew.  The same is also true of computer languages.  Programming languages such as Cobol, Fortran, and Pascal are rarely ever used anymore except for very specific purposes.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Each computer language has its advantages and disadvantages, just as human languages.  BASICA, for instance, is a very easy language to learn but it is limited and extremely slow.  C++, on the other hand, is harder to learn but is extremely fast.  For this reason and others, computer languages are picked by a programmer according to the problem they wish to solve.  The computer language Fortran, for instance, is great at solving math problems.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;You&#39;re still probably asking yourself, &quot;Why do we need to program a computer?&quot;  The simplest answer is because the computer cannot do anything without it being told what to do.  It must be told by someone how to do everything, including what steps to go through when it is turned on!  The only way to tell a computer how to do something is to write a program to tell it what to do.  In order to do this, the programmer must know what the problem is that is needing to be solved and must also know the computer language in which to solve.  If these two things are known, a program can be easily written to solve the problem.  The problem could be as simple as how to write a word onto the screen or as complex as flying the space shuttle.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;This book is intended to teach anyone how to program a personal computer.  A basic understanding of how to use a computer [preferably one that has been programmed so that it is usable &lt;span style=&quot;font-family: Wingdings;&quot;&gt;J&lt;/span&gt;], and an understanding of basic middle school Algebra is also helpful.  I plan to cover some of the more common languages used such as C, C++, Java, and HTML and also some of the lesser-used languages such as Qbasic and Assembly.  Some of the more complex languages, such as Java and Assembly, will be handled near the end of the book to allow important topics to be covered and explained thoroughly.  Other languages, specifically HTML, will be covered first and only within the first few chapters as they are not complex languages.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;This book is not meant to be an all-inclusive reference to each of these languages.  If it were, this book would be several thousand pages long.  It is meant to be an introduction only.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;h2&gt;&lt;span xmlns=&quot;&quot;&gt;Conventions&lt;br /&gt;
&lt;/span&gt;&lt;/h2&gt;&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;There will be several places within this book where code, new terms, user input, and so forth will be used within the text.  The table below shows how each of these conventions will look throughout the book.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&lt;br /&gt;
&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;&lt;table border=&quot;0&quot; style=&quot;border-collapse: collapse;&quot;&gt;&lt;colgroup&gt;&lt;col style=&quot;width: 295px;&quot;&gt;&lt;/col&gt;&lt;col style=&quot;width: 295px;&quot;&gt;&lt;/col&gt;&lt;/colgroup&gt;&lt;tbody valign=&quot;top&quot;&gt;
&lt;tr style=&quot;background: none repeat scroll 0% 0% rgb(230, 230, 230);&quot;&gt;&lt;td style=&quot;border: 0.5pt solid; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;b&gt;Convention&lt;/b&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: solid solid solid none; border-width: 0.5pt 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;b&gt;Meaning&lt;/b&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 12pt;&quot;&gt;&lt;b&gt;Bold&lt;/b&gt;&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;New term&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;Code&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;In-text code.  Usually just a single command or line&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;margin-left: 43pt;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;Program&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;Multi-line code segment or program.  Lines will be indented slightly from the book&#39;s text&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;&lt;i&gt;computer output&lt;/i&gt;&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;Computer&#39;s output from a program&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Courier New; font-size: 12pt;&quot;&gt;&lt;b&gt;user input&lt;/b&gt;&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;User&#39;s input into a program&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid; border-width: medium 0.5pt 0.5pt; padding-left: 7px; padding-right: 7px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;color: red; font-family: Times New Roman; font-size: 12pt;&quot;&gt;&lt;b&gt;Error&lt;/b&gt;&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-color: -moz-use-text-color; border-style: none solid solid none; border-width: medium 0.5pt 0.5pt medium; padding-left: 7px; padding-right: 7px;&quot;&gt;Error or mistake within program or an error that the computer produced&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span xmlns=&quot;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman; font-size: 10pt;&quot;&gt;&lt;b&gt;Table 1 – &lt;/b&gt;Conventions used throughout the text&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;h2&gt;&lt;span xmlns=&quot;&quot;&gt;An Apology&lt;br /&gt;
&lt;/span&gt;&lt;/h2&gt;&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;The computer field has been around for over 50 years and it has added many words to the English language.  In many instances there are multiple words to mean the exact same thing.  I will try to stick to the same set of terms throughout the entire book, but if I slip, please forgive me.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Also, computer programming is not an easy topic to explain at times.  I will do my best to explain it, but if I confuse you, forgive me.  Sometimes it is best to just sit down and experiment with a new concept and to figure out how it works yourself.  You will not make the computer blow up if you do something wrong.  The worst that could happen (at the introductory level anyway) is that you may have to reset the computer.  Experimentation is always the best way to learn, especially when dealing with computers.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&lt;br /&gt;
&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;h2&gt;&lt;span xmlns=&quot;&quot;&gt;Special Thanks&lt;br /&gt;
&lt;/span&gt;&lt;/h2&gt;&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;A special thanks to Heather Rawlins who got me to write this book in the first place and for always being there for me.  To Mrs. Pam Leary for showing me how to add two plus two in BASIC on an old TRS-80 Model III many years ago.  To Microsoft for creating the tools and languages to allow programmers to create their own software.  To all my friends who have put up with me through the years.  To Dr. Abrahamson, Dr. Wirth, and Dr. Prichard from East Carolina University for putting up with all my questions, allowing me to catch their mistakes without getting too mad, and for teaching me more about computer science.  &lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;If I&#39;ve missed anyone, it&#39;s not that I haven&#39;t thought about putting you in here.  I don&#39;t want to write a book of just &quot;thank you&quot;&#39;s.  If I&#39;ve offended anyone by not including you in here, email me and complain about it.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span xmlns=&quot;&quot;&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://rhale78.blogspot.com/feeds/5083353388789518281/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://rhale78.blogspot.com/2010/02/intro-to-computer-science-preface.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/270091469191232126/posts/default/5083353388789518281'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/270091469191232126/posts/default/5083353388789518281'/><link rel='alternate' type='text/html' href='http://rhale78.blogspot.com/2010/02/intro-to-computer-science-preface.html' title='Intro to Computer Science – Preface'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/09185478558704427023</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-270091469191232126.post-4653819596254170116</id><published>2010-02-26T17:46:00.001-05:00</published><updated>2010-02-26T17:46:00.112-05:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Intro to Computer Programming"/><title type='text'>Intro to Computer Programming - Legal</title><content type='html'>The information contained within this document does not contain any warranty.  The code has been tested on my machine to not cause damage and has been reviewed by university professors and other programmers but it is not guaranteed to do exactly what it should.  The reader takes full responsibility for executing the code samples contained within.  Any damage caused by the information or programs contained herein are the reader’s responsibility.&lt;br /&gt;
&lt;br /&gt;
All terms, trademarks, and copyrights are property of their respective owners.&lt;br /&gt;
&lt;br /&gt;
MS-DOS, Qbasic, QuickBasic, BASICA, C#, Internet Explorer, Microsoft Office Suite [including Word, Excel, Access, PowerPoint, FrontPage], and the Visual Studio Suite [including Visual Basic, C++, FoxPro, InterDev, and J++] are all registered trademarks and Windows is a trademark of Microsoft Corporation.&lt;br /&gt;
&lt;br /&gt;
Java is a registered trademark of Sun Microsystems.&lt;br /&gt;
&lt;br /&gt;
Turbo Pascal is a registered trademark of Borland Corporation.&lt;br /&gt;
&lt;br /&gt;
Netscape Communicator is a registered trademark of Netscape Corporation.&lt;br /&gt;
&lt;br /&gt;
Pentium is a registered trademark of Intel Corporation.&lt;br /&gt;
&lt;br /&gt;
All rights reserved.  No part of this document may be reproduced either in printed, written, nor digital form without the express written permission from the author.&lt;br /&gt;
&lt;br /&gt;
Copyright 2001 by Randy Hale.</content><link rel='replies' type='application/atom+xml' href='http://rhale78.blogspot.com/feeds/4653819596254170116/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://rhale78.blogspot.com/2010/02/intro-to-computer-programming-legal.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/270091469191232126/posts/default/4653819596254170116'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/270091469191232126/posts/default/4653819596254170116'/><link rel='alternate' type='text/html' href='http://rhale78.blogspot.com/2010/02/intro-to-computer-programming-legal.html' title='Intro to Computer Programming - Legal'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/09185478558704427023</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-270091469191232126.post-231890957578315975</id><published>2010-02-26T17:45:00.001-05:00</published><updated>2010-02-26T17:45:00.154-05:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Intro to Computer Programming"/><title type='text'>Intro to Computer Programming - Blog Intro</title><content type='html'>I started writing this multi-language (QB, C, C++) approach to an into to computer programming while in college as a personal side project.&amp;nbsp; I haven&#39;t touched it in over 8 years so I figured it was about time to release it to the public.&amp;nbsp; Maybe someone out there could use it or learn something from it.&amp;nbsp; It is in no means finished and has not been edited in any way.&lt;br /&gt;
I&#39;ll post this in a chapter format - it is kinda large as a whole so that&#39;ll probably be the easiest way.&lt;br /&gt;
Questions, comments, donations :), etc are all welcome.</content><link rel='replies' type='application/atom+xml' href='http://rhale78.blogspot.com/feeds/231890957578315975/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://rhale78.blogspot.com/2010/02/intro-to-computer-programming-blog.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/270091469191232126/posts/default/231890957578315975'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/270091469191232126/posts/default/231890957578315975'/><link rel='alternate' type='text/html' href='http://rhale78.blogspot.com/2010/02/intro-to-computer-programming-blog.html' title='Intro to Computer Programming - Blog Intro'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/09185478558704427023</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-270091469191232126.post-6567443151021720639</id><published>2010-02-18T17:32:00.001-05:00</published><updated>2010-02-18T17:32:00.421-05:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Asus"/><category scheme="http://www.blogger.com/atom/ns#" term="blu ray drives"/><category scheme="http://www.blogger.com/atom/ns#" term="computer build"/><category scheme="http://www.blogger.com/atom/ns#" term="computer cases"/><category scheme="http://www.blogger.com/atom/ns#" term="hard drive"/><category scheme="http://www.blogger.com/atom/ns#" term="Intel vs AMD"/><category scheme="http://www.blogger.com/atom/ns#" term="motherboards"/><category scheme="http://www.blogger.com/atom/ns#" term="power supply"/><title type='text'>First Blogged System Build</title><content type='html'>After over 14 years (probably closer to 16) of building computers, I&#39;ve never documented a build.&amp;nbsp; So, with the chance to build a semi-high performance system, I figured I&#39;d do at least one documented build - and with today&#39;s internet technology, I may as well blog it. :)&amp;nbsp; Please forgive the formatting - first time doing any major blogging :)&lt;br /&gt;
&lt;br /&gt;
The customer who wanted this system wanted a high performance system w/ monitor and printer for around $1400.&amp;nbsp; We went through the traditional questions of &quot;what are you using this computer for&quot; and&amp;nbsp;&quot;any special requests&quot;?&amp;nbsp; Basically, he wanted a system that he could easily upgrade, one that was a good performer for the price, price was somewhat important, this was going to be the main system in the house (with several children), he would not be playing major games on the system (i.e. no AfterShock but maybe Flash-based internet games/card games), he preferred to not &quot;have&quot; to upgrade this system for 2-3 years, the system had to have enough space to store music and video (i.e. 1TB), had to have CD/DVD writing capability, etc.&amp;nbsp; Well, I went out and with those requests found prices on several component choices and &quot;pre-built&quot; a couple systems on paper to get a rough cost.&amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
Basically, the 3 systems, a entry-level (~$1100), a mid-level (~$1400), and a super performance&amp;nbsp;(~$2400) included a 21&quot; Samsung Monitor (&lt;a href=&quot;http://www.amazon.com/Samsung-2233SW-21-5-Inch-Widescreen-Monitor/dp/B001QVLD8A?ie=UTF8&amp;amp;tag=randsblog-20&amp;amp;link_code=btl&amp;amp;camp=213689&amp;amp;creative=392969&quot; target=&quot;_blank&quot;&gt;Samsung 2233SW 21.5-Inch Full HD Widescreen LCD Monitor&lt;/a&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://www.assoc-amazon.com/e/ir?t=randsblog-20&amp;amp;l=btl&amp;amp;camp=213689&amp;amp;creative=392969&amp;amp;o=1&amp;amp;a=B001QVLD8A&quot; style=&quot;border: medium none; margin: 0px; padding: 0px ! important;&quot; width=&quot;1&quot; /&gt;) and&amp;nbsp;the Epson Workforce 610 which my wife and I have been extremely pleased with (&lt;a href=&quot;http://www.amazon.com/Epson-Workforce-Wireless-Printer-C11CA50201/dp/B002JM1XOY?ie=UTF8&amp;amp;tag=randsblog-20&amp;amp;link_code=btl&amp;amp;camp=213689&amp;amp;creative=392969&quot; target=&quot;_blank&quot;&gt;Epson Workforce 610 Wireless Color Inkjet All-in-One Printer (C11CA50201)&lt;/a&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://www.assoc-amazon.com/e/ir?t=randsblog-20&amp;amp;l=btl&amp;amp;camp=213689&amp;amp;creative=392969&amp;amp;o=1&amp;amp;a=B002JM1XOY&quot; style=&quot;border: medium none; margin: 0px; padding: 0px ! important;&quot; width=&quot;1&quot; /&gt;) as their non system base.&amp;nbsp; The 3 systems had was an Asus motherboard base, an AMD CPU, and, if the motherboard didn&#39;t have on-board video, an ATI graphics card.&amp;nbsp; The Asus, AMD, and ATI were my own preference choices for various reasons.&lt;br /&gt;
&lt;br /&gt;
After talking with the customer on the various options, we choose the new Asus EVO/U3S6 (&lt;a href=&quot;http://www.amazon.com/Asus-M4A785TD-V-EVO-Motherboard/dp/B002IVVB3E?ie=UTF8&amp;amp;tag=randsblog-20&amp;amp;link_code=btl&amp;amp;camp=213689&amp;amp;creative=392969&quot; target=&quot;_blank&quot;&gt;Asus M4A785TD-V Motherboard&lt;/a&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://www.assoc-amazon.com/e/ir?t=randsblog-20&amp;amp;l=btl&amp;amp;camp=213689&amp;amp;creative=392969&amp;amp;o=1&amp;amp;a=B002IVVB3E&quot; style=&quot;border: medium none; margin: 0px; padding: 0px ! important;&quot; width=&quot;1&quot; /&gt;)* {note - Amazon does not have the U3S6, this is the base motherboard link}&amp;nbsp; (the NewEgg link is &lt;a href=&quot;http://www.newegg.com/Product/Product.aspx?Item=N82E16813131627&quot;&gt;M4A785TD-V EVO/U3S6&lt;/a&gt;).&amp;nbsp; This specific motherboard features USB 3.0 as well as SATA III (i.e. 6Gbs) and has an onboard ATI 4200 video card...and, yes, the USB 3 and SATA III are off-board on a controller card - not a major problem for me.&amp;nbsp; This board also has fairly substantial overclocking capabilities, supports up to 16gb ram, has 5 on-board SATA II ports, and 6 USB 2.0 ports.&amp;nbsp; In addition to 2 SATA III ports, 2 USB 3.0 ports, HDMI, on-board sound (what motherboard doesn&#39;t nowadays), eSATA, COM1 and LPT1 ports (? yes, ports for legacy COM1 and legacy LPT1).&amp;nbsp; The on-board video is also decent and can easily be&amp;nbsp;combined with another 4200 off board card for even more performance - and, for&amp;nbsp;what this will be used for, no need to go with a high-end video card.&amp;nbsp; No, this is not the most feature rich board but I know the Asus brand and have been extremely impressed with their quality and their warranty on their hardware and computers.&amp;nbsp; I&#39;ll stick with what I trust and use myself.&amp;nbsp; [I&#39;ve also used and really like Abit boards but NewEgg did not have *any* Abit boards and Amazon did not have any Abit SATA III boards].&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;For the processor, I gave the customer a choice of the AMD Phenom II X2 (&lt;a href=&quot;http://www.amazon.com/Phenom-545-3-0GHZ-45NM-4000MHZ/dp/B002HLVO5A?ie=UTF8&amp;amp;tag=randsblog-20&amp;amp;link_code=btl&amp;amp;camp=213689&amp;amp;creative=392969&quot; target=&quot;_blank&quot;&gt;Phenom II X2 545 AM3 3.0GHZ 7MB 45NM 80W 4000MHZ Pib&lt;/a&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://www.assoc-amazon.com/e/ir?t=randsblog-20&amp;amp;l=btl&amp;amp;camp=213689&amp;amp;creative=392969&amp;amp;o=1&amp;amp;a=B002HLVO5A&quot; style=&quot;border: medium none; margin: 0px; padding: 0px ! important;&quot; width=&quot;1&quot; /&gt;) on up to the X4 (&lt;a href=&quot;http://www.amazon.com/AMD-HDZ965FBGIBOX-Phenom-Central-Processing/dp/B002KV6MLS?ie=UTF8&amp;amp;tag=randsblog-20&amp;amp;link_code=btl&amp;amp;camp=213689&amp;amp;creative=392969&quot; target=&quot;_blank&quot;&gt;AMD HDZ965FBGIBOX Phenom II X4 965 3.4GHZ Central Processing Unit (Black)&lt;/a&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://www.assoc-amazon.com/e/ir?t=randsblog-20&amp;amp;l=btl&amp;amp;camp=213689&amp;amp;creative=392969&amp;amp;o=1&amp;amp;a=B002KV6MLS&quot; style=&quot;border: medium none; margin: 0px; padding: 0px ! important;&quot; width=&quot;1&quot; /&gt;) and several Ghz choices within each of those.&amp;nbsp; He choose the mid-range &lt;a href=&quot;http://www.amazon.com/AMD-Phenom-HDX945FBGIBOX-125W-Processor/dp/B00273JQ26?ie=UTF8&amp;amp;tag=randsblog-20&amp;amp;link_code=btl&amp;amp;camp=213689&amp;amp;creative=392969&quot; target=&quot;_blank&quot;&gt;AMD Phenom II X4 945 HDX945FBGIBOX 3.0 GHz/6MB L3/125W Processor&lt;/a&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://www.assoc-amazon.com/e/ir?t=randsblog-20&amp;amp;l=btl&amp;amp;camp=213689&amp;amp;creative=392969&amp;amp;o=1&amp;amp;a=B00273JQ26&quot; style=&quot;border: medium none; margin: 0px; padding: 0px ! important;&quot; width=&quot;1&quot; /&gt;.&amp;nbsp; For the price, it ended up being the best price point.&amp;nbsp; I went ahead and kept the stock fan/heat sink as I knew we would get a case that had plenty of airflow and I don&#39;t foresee this customer overclocking the machine any.&amp;nbsp; And, another good word for AMD, I&#39;ve never had any problems with their stock fans/heatsinks - it&#39;s always been the stock Intel that I&#39;ve had major problems with.&lt;br /&gt;
&lt;br /&gt;
In terms of memory, I told him he would be running 64-bit (i.e. no, he had no choice :)).&amp;nbsp; So, 4gb is the minimum I recommended.&amp;nbsp; He would be running Windows 7 on this machine and the applications he mentioned he may use would not be anything that would tax the memory.&amp;nbsp; So, we both decided to stay at 4gb with the option available to add another 4gb (2x2gb) at a later time.&amp;nbsp; I choose the &lt;a href=&quot;http://www.amazon.com/G-Skill-F3-12800CL9D-4GBNQ-Dual-Channel-unbuffered/dp/B001IWZDME?ie=UTF8&amp;amp;tag=randsblog-20&amp;amp;link_code=btl&amp;amp;camp=213689&amp;amp;creative=392969&quot; target=&quot;_blank&quot;&gt;G.Skill NQ Series F3-12800CL9D-4GBNQ Dual Channel - Memory - 4 GB ( 2 x 2 GB ) - DIMM 240-pin - DDR3 - 1600 MHz / PC3-12800 - CL9 - 1.8 V - unbuffered - non-ECC&lt;/a&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://www.assoc-amazon.com/e/ir?t=randsblog-20&amp;amp;l=btl&amp;amp;camp=213689&amp;amp;creative=392969&amp;amp;o=1&amp;amp;a=B001IWZDME&quot; style=&quot;border: medium none; margin: 0px; padding: 0px ! important;&quot; width=&quot;1&quot; /&gt;.&amp;nbsp; Even though the motherboard could support the higher speed memory, I stayed with a mid-range speed...I personally have not seen a significant speed improvement for using higher speed memory - there are many other slowdown areas that should be addressed before memory speed is increased (i.e. hard drive RPM speed is a much more significant speed problem than a 300-600Mhz difference in memory speed).&amp;nbsp; And, yet another AMD advantage over Intel for DDR3 memory - AMD allows using dual channel memory (2 memory slots used)...Intel requires ternary channels (3 memory slots used)...again, lower cost for AMD vs Intel and also lower amount of heat dispersed into the case (lower wattage required, etc).&amp;nbsp; Yes, there may be minor differences between dual and ternary channel memory but not enough to make me switch to Intel (and spend more).&lt;br /&gt;
&lt;br /&gt;
Next came the hard drive.&amp;nbsp; There were several options here.&amp;nbsp; We ended up, after a long debate, with the &lt;a href=&quot;http://www.amazon.com/Western-Digital-Caviar-Black-WD1001FALS/dp/B001C271MA?ie=UTF8&amp;amp;tag=randsblog-20&amp;amp;link_code=btl&amp;amp;camp=213689&amp;amp;creative=392969&quot; target=&quot;_blank&quot;&gt;Western Digital Caviar Black 1 TB Bulk/OEM Hard Drive 3.5 Inch, 32 MB Cache, 7200 RPM SATA II WD1001FALS&lt;/a&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://www.assoc-amazon.com/e/ir?t=randsblog-20&amp;amp;l=btl&amp;amp;camp=213689&amp;amp;creative=392969&amp;amp;o=1&amp;amp;a=B001C271MA&quot; style=&quot;border: medium none; margin: 0px; padding: 0px ! important;&quot; width=&quot;1&quot; /&gt;.&amp;nbsp; [We had picked a Samsung but NewEgg was sold out when I made the order].&amp;nbsp; We had talked about the 7200 RPM drives vs the 10000RPM (&lt;a href=&quot;http://www.amazon.com/Western-Digital-VelociRaptor-WD3000HLFS-Frustration-Free/dp/B001FBH0HE?ie=UTF8&amp;amp;tag=randsblog-20&amp;amp;link_code=btl&amp;amp;camp=213689&amp;amp;creative=392969&quot; target=&quot;_blank&quot;&gt;Western Digital 300 GB VelociRaptor SATA 10,000 RPM 16 MB Cache Bulk/OEM Desktop Hard Drive WD3000HLFS&lt;/a&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://www.assoc-amazon.com/e/ir?t=randsblog-20&amp;amp;l=btl&amp;amp;camp=213689&amp;amp;creative=392969&amp;amp;o=1&amp;amp;a=B001FBH0HE&quot; style=&quot;border: medium none; margin: 0px; padding: 0px ! important;&quot; width=&quot;1&quot; /&gt;) drives but the price per gigabyte vs performance was a bit much.&amp;nbsp; Yes,&amp;nbsp;10k RPM drives are FAST but for $200 for 300gb vs $100 for 1TB - not worth it for general use.&amp;nbsp; We also went back and forth over the new SATA III 6Gbps drives but from what I read of the ratings, the speed and performance for those new drives just isn&#39;t up to the speed yet and with the standard so new I suggested he hold off and get those drives later after more manufactures get on board (there was only 1 when I did the research - I found none just now on Amazon and NewEgg, so maybe a very good choice to, for once,&amp;nbsp;avoid the bleeding edge!).&amp;nbsp; This drive is in Western Digital&#39;s line of similar drives - green being &quot;green&quot; which uses less power and are very quiet, blue which is general use, and black which is a performance drive.&amp;nbsp; After installing this drive into the system, this drive seemed &quot;noisy&quot; compared to others I&#39;ve used...but, this could be due to the acoustics of the case or the drive itself...doesn&#39;t sound bad&amp;nbsp;and not overly loud&amp;nbsp;but can be heard over the fans.&amp;nbsp; The only caution with this drive is that it is not natively RAIDable...there&#39;s supposed to be a &quot;trick&quot; out there to force the RLE disabled/enabled but I didn&#39;t bother as this drive is currently not RAIDed.&amp;nbsp; Of course you must pay WD more if you want the native RAIDable drive...i.e. not worth it...&amp;nbsp; For the high performance system, I had included in the price 2 1.5tg 6gb drives and 3 of the 300gb 10k RPM drives...&lt;br /&gt;
&lt;br /&gt;
The customer wanted to be able to write CDs and DVDs...after looking at the prices ($30 for a DVD writer), and seeing the price on the Blu-Ray Combo drive (&lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://www.assoc-amazon.com/e/ir?t=randsblog-20&amp;amp;l=btl&amp;amp;camp=213689&amp;amp;creative=392969&amp;amp;o=1&amp;amp;a=B002CHPH8Y&quot; style=&quot;border: medium none; margin: 0px; padding: 0px ! important;&quot; width=&quot;1&quot; /&gt;&lt;a href=&quot;http://www.amazon.com/Electronics-LightScribe-UH08LS10-BLACK-RBOX/dp/B002NZG3ZQ?ie=UTF8&amp;amp;tag=randsblog-20&amp;amp;link_code=btl&amp;amp;camp=213689&amp;amp;creative=392969&quot; target=&quot;_blank&quot;&gt;LG Electronics LightScribe 8x SATA Blu-ray Combo Internal Drive UH08LS10 BLACK/RBOX (Black)&lt;/a&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://www.assoc-amazon.com/e/ir?t=randsblog-20&amp;amp;l=btl&amp;amp;camp=213689&amp;amp;creative=392969&amp;amp;o=1&amp;amp;a=B002NZG3ZQ&quot; style=&quot;border: medium none; margin: 0px; padding: 0px ! important;&quot; width=&quot;1&quot; /&gt;), we choose to get the Blu Ray drive.&amp;nbsp; This&#39;ll be my first Blu Ray drive installed [hey, I haven&#39;t been building systems much lately] and so far so good...haven&#39;t yet tested the Blu Ray capability but normal reading seems to be very quick and for ~$90, not a bad price at all for a Blu Ray Player.&lt;br /&gt;
&lt;br /&gt;
After how many years of not using a floppy for storage, I decided to not use a floppy drive on this system.&amp;nbsp; Flash drives are much more reliable and cheaper.&lt;br /&gt;
&lt;br /&gt;
I got a generic keyboard and mouse - these are a lot personal preference so I got the cheapest available that worked and they can update as needed.&lt;br /&gt;
&lt;br /&gt;
The power supply is the old reliable Antec Earthwatts 650 (&lt;a href=&quot;http://www.amazon.com/650-Watt-ATX12V-V2-2-Psu/dp/B000HEZFZO?ie=UTF8&amp;amp;tag=randsblog-20&amp;amp;link_code=btl&amp;amp;camp=213689&amp;amp;creative=392969&quot; target=&quot;_blank&quot;&gt;650 Watt ATX12V V2.2 Psu&lt;/a&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://www.assoc-amazon.com/e/ir?t=randsblog-20&amp;amp;l=btl&amp;amp;camp=213689&amp;amp;creative=392969&amp;amp;o=1&amp;amp;a=B000HEZFZO&quot; style=&quot;border: medium none; margin: 0px; padding: 0px ! important;&quot; width=&quot;1&quot; /&gt;).&amp;nbsp; I&#39;ve used these many times in several of my home systems and for repairs and they do a great job.&amp;nbsp; They don&#39;t generate a lot of heat and have very reliable components.&amp;nbsp; They&#39;re also 80%+ efficient which helps with the electric bill.&amp;nbsp; The only thing I don&#39;t like is their cables are not modular, but, they do have pretty much all the cables you&#39;d need.&amp;nbsp; Probably not the best for the tight-fit case but in a large case, modularity is not a problem.&amp;nbsp; For this system and for upgrade reasons, I didn&#39;t recommend anything below a 500w so this was the best available choice.&lt;br /&gt;
&lt;br /&gt;
The case...ah, this is probably one of my favorite parts of the build.&amp;nbsp; I&#39;ve really been a fan of Antec cases (I personally have the P180 (&lt;a href=&quot;http://www.amazon.com/Antec-P180-Advanced-Super-Steel/dp/B0009PD3SW?ie=UTF8&amp;amp;tag=randsblog-20&amp;amp;link_code=btl&amp;amp;camp=213689&amp;amp;creative=392969&quot; target=&quot;_blank&quot;&gt;Antec P180 Advanced Super Steel Mid Tower ATX Case&lt;/a&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://www.assoc-amazon.com/e/ir?t=randsblog-20&amp;amp;l=btl&amp;amp;camp=213689&amp;amp;creative=392969&amp;amp;o=1&amp;amp;a=B0009PD3SW&quot; style=&quot;border: medium none; margin: 0px; padding: 0px ! important;&quot; width=&quot;1&quot; /&gt;) and the P182 (&lt;a href=&quot;http://www.amazon.com/Antec-P182-Advanced-Super-Stainless/dp/B000P0CTSQ?ie=UTF8&amp;amp;tag=randsblog-20&amp;amp;link_code=btl&amp;amp;camp=213689&amp;amp;creative=392969&quot; target=&quot;_blank&quot;&gt;Antec P182 Advanced Super Mid Tower ATX Case (Black/Stainless Steel Trim)&lt;/a&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://www.assoc-amazon.com/e/ir?t=randsblog-20&amp;amp;l=btl&amp;amp;camp=213689&amp;amp;creative=392969&amp;amp;o=1&amp;amp;a=B000P0CTSQ&quot; style=&quot;border: medium none; margin: 0px; padding: 0px ! important;&quot; width=&quot;1&quot; /&gt;)).&amp;nbsp; For this build, with an unknown amount of heat generated from the CPU, I decided to go with something with a bit more air flow (the Antecs do a great job, don&#39;t get me wrong) and something not so heavy (the Antecs are 50lbs+) and something easy to upgrade.&amp;nbsp; I looked at two, an &lt;a href=&quot;http://www.newegg.com/Product/Product.aspx?Item=N82E16811103011&quot;&gt;XCLIO Windtunnel&lt;/a&gt;&amp;nbsp;with its two huge external fans or the RaidMax Smilodon (&lt;a href=&quot;http://www.amazon.com/RaidMax-Elite-Smilodon-612W-supply/dp/B000MXVDKQ?ie=UTF8&amp;amp;tag=randsblog-20&amp;amp;link_code=btl&amp;amp;camp=213689&amp;amp;creative=392969&quot; target=&quot;_blank&quot;&gt;RaidMax Elite Series Smilodon 612W - Mid tower - ATX - power supply 500 Watt - black - USB/Audio&lt;/a&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://www.assoc-amazon.com/e/ir?t=randsblog-20&amp;amp;l=btl&amp;amp;camp=213689&amp;amp;creative=392969&amp;amp;o=1&amp;amp;a=B000MXVDKQ&quot; style=&quot;border: medium none; margin: 0px; padding: 0px ! important;&quot; width=&quot;1&quot; /&gt;) with its foldout motherboard tray.&amp;nbsp; I talked to the customer and we decided to go with the one with the most air flow - the XCLIO Windtunnel.&amp;nbsp; All I&#39;ll say is this case is a pleasure to work with.&amp;nbsp; The external fans are beasts and are adjustable and can be powered off at will.&amp;nbsp; The case has plenty of room, great air flow (even with the external fans off), easy to get the motherboard installed, screwdriver-less installation of all drives.&amp;nbsp; Pretty nice.&amp;nbsp; The only gripes I have are the edges are sharp - but that&#39;s common with a lot of cases, the hard drive carriers are a bit of a pain to get onto the drives and don&#39;t appear as easy to remove once they&#39;re on the drives...but, being in a caddy, they&#39;re ok (if you&#39;re looking at swapping hard drives a lot - avoid!).&amp;nbsp; The DVD drive was a cinch to install.&amp;nbsp; I do wish the power cable for the external fans were a bit longer but other than that, not bad.&amp;nbsp; This case only comes with the external fans, the drive fan and back external fan are optional - but I highly doubt are needed.&amp;nbsp; The case is a bit taller than my Antec P182 and not as weighty (30lbs).&amp;nbsp; Oh, another small thing, be careful of the front panel, lifting the case the panel is plastic and doesn&#39;t appear to be able to hold the weight well.&amp;nbsp; The case also has adjustable feet, which is a nice change to the rubber &quot;feet&quot; I&#39;m used to.&amp;nbsp; The front panel is pretty thick and hides the drives and power/reset buttons.&amp;nbsp; The USB/audio ports are on the side...interesting.&amp;nbsp; Unlike the Antecs, this case does NOT have any air filters...and with all the incoming air, internal dust might be a problem.&amp;nbsp; The hard drive did seem loud but not sure if this is the hard drive or the case&#39;s fault.&amp;nbsp; Rubber grommets would be a nice addition (i.e. like Antec&#39;s P180 series).&amp;nbsp; Overall, I did like the case (yes, against all my gripes - just documenting everything) and would definitely buy it again for another high performance system.&amp;nbsp; The fans are adjustable and are surprisingly quiet!&amp;nbsp; The side panel is a pain to get on at times (goes on but the thumbscrews don&#39;t always align) and it does not come off the way most normally do - it comes up (up being case on it&#39;s side) , not back (back as in drives towards power supply).&amp;nbsp; Took some getting used to...&amp;nbsp; With it all said and done and everything built, the case temp was &amp;lt;30C and CPU temp &amp;lt;30C (BIOS temps) and the exhaust air was very cool (unlike one of my Intel-based Antec&#39;s with air fairly warm).&amp;nbsp; Even with the external fans off, the CPU/case temp did not go above 32C (BIOS temps).&amp;nbsp; A few of the case pics are below...&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://static.pixelpipe.com/0e339403-b607-4ab8-992c-a6ebbb6ddff8_b.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;149&quot; src=&quot;http://static.pixelpipe.com/0e339403-b607-4ab8-992c-a6ebbb6ddff8_b.jpg&quot; style=&quot;max-width: 100%;&quot; width=&quot;200&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://static.pixelpipe.com/f508db42-f040-4386-bac7-7f8d20d5e690_b.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;149&quot; src=&quot;http://static.pixelpipe.com/f508db42-f040-4386-bac7-7f8d20d5e690_b.jpg&quot; style=&quot;max-width: 100%;&quot; width=&quot;200&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;img height=&quot;149&quot; src=&quot;http://static.pixelpipe.com/2ec40d24-9fad-420d-9a0e-fb2db4344c4b_b.jpg&quot; style=&quot;max-width: 100%;&quot; width=&quot;200&quot; /&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;pp_item&quot;&gt;&lt;div style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;pp_item&quot;&gt;&lt;div style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img height=&quot;149&quot; src=&quot;http://static.pixelpipe.com/bebd6c3a-db54-427e-ba93-a23908cbdf52_b.jpg&quot; style=&quot;max-width: 100%;&quot; width=&quot;200&quot; /&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;pp_item&quot;&gt;&lt;/div&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;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://static.pixelpipe.com/6a7b33b4-792e-4a59-a098-510821a5c50e_b.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;149&quot; src=&quot;http://static.pixelpipe.com/6a7b33b4-792e-4a59-a098-510821a5c50e_b.jpg&quot; style=&quot;max-width: 100%;&quot; width=&quot;200&quot; /&gt;&lt;/a&gt;&lt;/div&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;
I had the entire system built in less than 2 hours.&amp;nbsp; Was a fairly easy build and I actually did take my time on it...the case made a huge difference.&lt;br /&gt;
&lt;br /&gt;
Installing software...I installed Windows 7 (upgrade version) [with no prior OS], it installed and it was ready to use in ~15 minutes.&amp;nbsp; Unfortunately, 7 did not like me trying to use an upgrade without an OS already installed (I know, I have not done any clean absolutely no OS installs of 7 before so I thought it would &quot;ask&quot; for an original XP/Vista CD&amp;nbsp;- it didn&#39;t).&amp;nbsp; So, Vista 64 install...also took ~20 minutes (yay, not SATA drivers needed!&amp;nbsp; Pleasant surprise!)...then installed 7 on-top of a clean Vista install.&amp;nbsp; Again, less than 15 minutes.&amp;nbsp; Everything else was a cake walk - nothing took over 5 minutes to install...actually probably took longer to download most things than to install them.&amp;nbsp; I installed Avast, Ad-aware, all the &quot;useful&quot; Asus utilities , Java, ATI display drivers, OpenOffice, Google utilities (minus Spyware Doctor as that&#39;s caused me problems on several other systems) along with all the LG utilities for reading/writing disks and watching Blu Rays.&amp;nbsp; I also installed the DivX player, which has a decent selection of HD videos and can encode videos fairly well.&amp;nbsp; Of course, Firefox was also installed.&amp;nbsp; Overall, I had everything installed and fully updated in just a couple hours.&lt;br /&gt;
&lt;br /&gt;
General testing went well and the machine performed great.&amp;nbsp; We&#39;ll see how well the customer likes this machine :)&amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
For the record, this time NewEgg instead of Amazon had the best prices for the parts where normally it&#39;s the opposite.&amp;nbsp; Sorry, Amazon - some parts just weren&#39;t available at all at Amazon.&amp;nbsp; And, yes, the total for this system was a little under $1400 including monitor, printer, computer, tax (stupid TN tax of ~$125!) and shipping/handling ($30! - yes, $30 and everything came in about a week).&lt;br /&gt;
&lt;br /&gt;
Since I have no clue (yet) how to arrange these pics, the various pics from the build are below.&lt;br /&gt;
&lt;div class=&quot;pp_items&quot;&gt;&lt;div align=&quot;center&quot; class=&quot;pp_item&quot;&gt;&lt;div style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;pp_item&quot;&gt;&lt;div style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img height=&quot;149&quot; src=&quot;http://static.pixelpipe.com/026157f1-f6b5-4017-af08-27fb15365ef7_b.jpg&quot; style=&quot;max-width: 100%;&quot; width=&quot;200&quot; /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;pp_item&quot;&gt;&lt;div style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img height=&quot;149&quot; src=&quot;http://static.pixelpipe.com/eb36d2db-11fc-4685-aaec-cdc2948237ce_b.jpg&quot; style=&quot;max-width: 100%;&quot; width=&quot;200&quot; /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;pp_item&quot;&gt;&lt;div style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img height=&quot;149&quot; src=&quot;http://static.pixelpipe.com/e863526d-355b-41cd-a3f3-1a7e4057d309_b.jpg&quot; style=&quot;max-width: 100%;&quot; width=&quot;200&quot; /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;pp_item&quot;&gt;&lt;div style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img height=&quot;149&quot; src=&quot;http://static.pixelpipe.com/01e0e5ef-8720-4305-8a5d-33093ccc4c53_b.jpg&quot; style=&quot;max-width: 100%;&quot; width=&quot;200&quot; /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;pp_item&quot;&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;pp_item&quot;&gt;&lt;div style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img height=&quot;200&quot; src=&quot;http://static.pixelpipe.com/e6008b6a-1626-44e9-826e-61bd732ac69a_b.jpg&quot; style=&quot;max-width: 100%;&quot; width=&quot;149&quot; /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;pp_item&quot;&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;pp_item&quot;&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;pp_item&quot;&gt;&lt;div style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img height=&quot;149&quot; src=&quot;http://static.pixelpipe.com/2b7fb610-ff9a-45d8-9558-e263c17a7080_b.jpg&quot; style=&quot;max-width: 100%;&quot; width=&quot;200&quot; /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;pp_item&quot;&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;pp_item&quot;&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;pp_item&quot;&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;pp_item&quot;&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;pp_item&quot;&gt;&lt;div style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img height=&quot;149&quot; src=&quot;http://static.pixelpipe.com/1247965d-da8f-4a96-bdb6-818f33b4f947_b.jpg&quot; style=&quot;max-width: 100%;&quot; width=&quot;200&quot; /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;pp_item&quot;&gt;&lt;div style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img height=&quot;149&quot; src=&quot;http://static.pixelpipe.com/3d5482e0-47ad-49ca-8429-695956fc4225_b.jpg&quot; style=&quot;max-width: 100%;&quot; width=&quot;200&quot; /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;pp_item&quot;&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;pp_item&quot;&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;pp_item&quot;&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;pp_item&quot;&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;pp_item&quot;&gt;&lt;div style=&quot;border: medium none;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;pp_item&quot;&gt;&lt;div style=&quot;border: medium none;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;pp_item&quot;&gt;&lt;div style=&quot;border: medium none;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;pp_item&quot;&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;pp_item&quot;&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;pp_item&quot;&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;pp_item&quot;&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;pp_item&quot;&gt;&lt;div style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img height=&quot;149&quot; src=&quot;http://static.pixelpipe.com/3a9ddbbd-9c8c-4808-9e70-15a298a1adb9_b.jpg&quot; style=&quot;max-width: 100%;&quot; width=&quot;200&quot; /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;pp_item&quot;&gt;&lt;div style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img height=&quot;149&quot; src=&quot;http://static.pixelpipe.com/3eb6b1bf-29b5-45ca-9598-2dc68f7a7551_b.jpg&quot; style=&quot;max-width: 100%;&quot; width=&quot;200&quot; /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;pp_item&quot;&gt;&lt;div style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img height=&quot;149&quot; src=&quot;http://static.pixelpipe.com/db88e27b-c6de-491f-b1ea-f76684b037bc_b.jpg&quot; style=&quot;max-width: 100%;&quot; width=&quot;200&quot; /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;pp_item&quot;&gt;&lt;div style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img height=&quot;200&quot; src=&quot;http://static.pixelpipe.com/950d2eda-4e81-4560-a6ae-2d6ce7bc9f82_b.jpg&quot; style=&quot;max-width: 100%;&quot; width=&quot;149&quot; /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;pp_item&quot;&gt;&lt;div style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img height=&quot;149&quot; src=&quot;http://static.pixelpipe.com/a514725f-b2cf-45ea-a94f-fc7ac135a384_b.jpg&quot; style=&quot;max-width: 100%;&quot; width=&quot;200&quot; /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;pp_item&quot;&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;pp_item&quot;&gt;&lt;div style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img height=&quot;149&quot; src=&quot;http://static.pixelpipe.com/d420cc4d-c757-4aa1-8bee-3ee751eba6c9_b.jpg&quot; style=&quot;max-width: 100%;&quot; width=&quot;200&quot; /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;pp_item&quot;&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;pp_item&quot;&gt;&lt;div style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img height=&quot;200&quot; src=&quot;http://static.pixelpipe.com/fb9e7baf-a521-4595-b7e0-24f74c3fd24f_b.jpg&quot; style=&quot;max-width: 100%;&quot; width=&quot;149&quot; /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;pp_item&quot;&gt;&lt;div style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img height=&quot;200&quot; src=&quot;http://static.pixelpipe.com/d33c2a63-b9f5-4d9f-a2c1-3803c944cc6e_b.jpg&quot; style=&quot;max-width: 100%;&quot; width=&quot;149&quot; /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;pp_item&quot;&gt;&lt;div style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img height=&quot;149&quot; src=&quot;http://static.pixelpipe.com/75b63090-2c33-4794-b5e1-f5cc44392d00_b.jpg&quot; style=&quot;max-width: 100%;&quot; width=&quot;200&quot; /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;pp_item&quot;&gt;&lt;div style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img height=&quot;149&quot; src=&quot;http://static.pixelpipe.com/3343797c-b214-45f2-8ea5-33ed4e28146c_b.jpg&quot; style=&quot;max-width: 100%;&quot; width=&quot;200&quot; /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;pp_item&quot;&gt;&lt;div style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img height=&quot;149&quot; src=&quot;http://static.pixelpipe.com/cbee9b01-c456-4c9f-9358-ac58766cb097_b.jpg&quot; style=&quot;max-width: 100%;&quot; width=&quot;200&quot; /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;pp_item&quot;&gt;&lt;div style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img height=&quot;149&quot; src=&quot;http://static.pixelpipe.com/5c0380a6-ec49-4be0-9e1e-1d739a28d072_b.jpg&quot; style=&quot;max-width: 100%;&quot; width=&quot;200&quot; /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;pp_item&quot;&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;pp_item&quot;&gt;&lt;div style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img height=&quot;149&quot; src=&quot;http://static.pixelpipe.com/d9880552-5224-426f-9afc-86db1f1baf92_b.jpg&quot; style=&quot;max-width: 100%;&quot; width=&quot;200&quot; /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;pp_item&quot;&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;pp_item&quot;&gt;&lt;div style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img height=&quot;149&quot; src=&quot;http://static.pixelpipe.com/d5ee9840-bb35-4f9e-99f8-cd0dba77a561_b.jpg&quot; style=&quot;max-width: 100%;&quot; width=&quot;200&quot; /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;pp_item&quot;&gt;&lt;div style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img height=&quot;149&quot; src=&quot;http://static.pixelpipe.com/4531b3bd-ab18-4fb0-83ab-446d4b08c9e0_b.jpg&quot; style=&quot;max-width: 100%;&quot; width=&quot;200&quot; /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;pp_item&quot;&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;pp_item&quot;&gt;&lt;div style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img height=&quot;149&quot; src=&quot;http://static.pixelpipe.com/9b88725b-0006-49ce-a52d-44712faeaeb3_b.jpg&quot; style=&quot;max-width: 100%;&quot; width=&quot;200&quot; /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;pp_item&quot;&gt;&lt;div style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img height=&quot;149&quot; src=&quot;http://static.pixelpipe.com/0a6f1ba2-16b4-45c0-aa1d-b8317f0b6520_b.jpg&quot; style=&quot;max-width: 100%;&quot; width=&quot;200&quot; /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;pp_item&quot;&gt;&lt;div style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img height=&quot;200&quot; src=&quot;http://static.pixelpipe.com/17c44acd-6276-4cc5-9942-93a6d574c85e_b.jpg&quot; style=&quot;max-width: 100%;&quot; width=&quot;149&quot; /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;pp_item&quot;&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;pp_item&quot;&gt;&lt;div style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img height=&quot;149&quot; src=&quot;http://static.pixelpipe.com/be6c4e1b-8146-4ba7-95ed-57c5b46a4a24_b.jpg&quot; style=&quot;max-width: 100%;&quot; width=&quot;200&quot; /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;pp_item&quot;&gt;&lt;div style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;pp_item&quot;&gt;&lt;div style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;pp_item&quot;&gt;&lt;div style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;pp_item&quot;&gt;&lt;div style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;pp_item&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;pp_item&quot;&gt;&lt;div style=&quot;border: medium none;&quot;&gt;&lt;div style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://static.pixelpipe.com/0e339403-b607-4ab8-992c-a6ebbb6ddff8_b.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;br /&gt;
&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;pp_item&quot;&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;pp_item&quot;&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;pp_item&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;border: medium none; clear: both; text-align: center;&quot;&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://rhale78.blogspot.com/feeds/6567443151021720639/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://rhale78.blogspot.com/2010/02/blog-post.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/270091469191232126/posts/default/6567443151021720639'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/270091469191232126/posts/default/6567443151021720639'/><link rel='alternate' type='text/html' href='http://rhale78.blogspot.com/2010/02/blog-post.html' title='First Blogged System Build'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/09185478558704427023</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-270091469191232126.post-7546352379597539094</id><published>2009-04-28T23:36:00.003-04:00</published><updated>2009-04-28T23:52:32.863-04:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="indexes"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL 08"/><title type='text'>SQL 2008 Resetting auto increment indexes</title><content type='html'>Found this useful for resetting the auto-increment indexes on a SQL 08 database.&lt;br /&gt;&lt;br /&gt;DBCC CHECKIDENT (&quot;database.dbo.tablename&quot;, RESEED, 0);&lt;br /&gt;&lt;br /&gt;No column name needed.</content><link rel='replies' type='application/atom+xml' href='http://rhale78.blogspot.com/feeds/7546352379597539094/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://rhale78.blogspot.com/2009/04/sql-2008-resetting-auto-increment.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/270091469191232126/posts/default/7546352379597539094'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/270091469191232126/posts/default/7546352379597539094'/><link rel='alternate' type='text/html' href='http://rhale78.blogspot.com/2009/04/sql-2008-resetting-auto-increment.html' title='SQL 2008 Resetting auto increment indexes'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/09185478558704427023</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>