<?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-7607138261163784346</id><updated>2025-10-21T23:58:18.186-07:00</updated><category term="Programs"/><category term="Introduction"/><category term="Built in Functions"/><title type='text'>C++ For Beginners</title><subtitle type='html'>Learn C++ Programming language For Beginners</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://cplspls.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7607138261163784346/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://cplspls.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/7607138261163784346/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>36</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-7607138261163784346.post-5803739539618071184</id><published>2017-08-22T13:55:00.003-07:00</published><updated>2017-08-22T13:57:21.831-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Programs"/><title type='text'>Check given String for Palindrome</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;b&gt;Program: Find given string is palindrome or not&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;/span&gt; &lt;span style=&quot;color: #333333; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;Palindrome:&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;background-color: white; color: #545454;&quot;&gt;A&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: white; color: #6a6a6a; font-weight: bold;&quot;&gt;palindrome&lt;/span&gt;&lt;span style=&quot;background-color: white; color: #545454;&quot;&gt;&amp;nbsp;is a word, phrase, number, or other sequence of characters which reads the same backward as forward, such as madam or racecar.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;/span&gt;  &lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;So in this program we take input string from user and return the result&amp;nbsp;whether its palindrome or not.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;#include &amp;lt;iostream&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;using namespace std;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;int main() {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;char str[100]; &lt;/span&gt;&lt;span style=&quot;color: #6aa84f; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;// declare char variable of length 100 i.e. max 100 character string can be taken input&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;cin &amp;gt;&amp;gt; str; &lt;/span&gt;&lt;span style=&quot;color: #6aa84f; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;//take input&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;int strLength = 0; &lt;/span&gt;&lt;span style=&quot;color: #6aa84f; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;//initialize the length of string to zero&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;bool palindrome = true; &lt;/span&gt;&lt;span style=&quot;color: #6aa84f; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;//let assume given string is palindrome&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;for(int i=0;str[i]!=&#39;\0&#39;;i++,strLength++);&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #6aa84f; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;/*&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #6aa84f; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&amp;nbsp;to understand above statement first remember array of char ends with &#39;\0&#39;. &#39;\0&#39; represents null character. So we can determine the end of string &#39;\0&#39; to calculate the length of string. So here we first initialize the length by 0 then we begin the loop from i =0 and we check character at i&lt;sup&gt;th&lt;/sup&gt;&amp;nbsp;position for null character &#39;\0&#39;, so we are increment string length with the value of i. So when we encounter &#39;\0&#39; it means end of string so length is calculate with the value of i.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #6aa84f; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;*/&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;for(int i=strLength-1,j=0;j&amp;lt;(strLength/2)+1;i--,j++){&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp;if(str[i] != str[j]){&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; palindrome = false;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; break;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #6aa84f; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;/*&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #6aa84f; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&amp;nbsp;Now to check palindrome we check starting half of string should be match with half from end. For even length it will divide perfect in two parts whereas for odd it will left with one character that we don&#39;t need to check as its in middle and common.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #6aa84f; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;Now we declare two counter first denote the position of start of string and other end of string[Remember index start from 0 so here strLength is total length so last Index will be strLength -1 ]. So we run the loop upto half length of string length and we increment j(start counter) and decrement i(end counter).&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #6aa84f; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;In each loop pass we check character of ith position and jth position to be same. If they mismatch in any one of the case then we can says given string is not a palindrome. So by default we assume its palindrome if condition doesn&#39;t match mean its palindrome.&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;color: #6aa84f; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;*/&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;if(palindrome){ &lt;/span&gt;&lt;span style=&quot;color: #6aa84f; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;//print the output&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;cout &amp;lt;&amp;lt; &quot;Given String is Palindrome&quot;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;else{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;cout &amp;lt;&amp;lt; &quot;Given String is not a Palindrome&quot;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;return 0;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgzXpI4FyRX4uQEczzdBmsy7U1klpbC-0WGhAr8t372jMMzAMY-vXntU6P4T5fp3EaOHGTWK1Y4p8NtgYe6-lBQ0sdujWJaNFh9bYLf2PizvldfAf13EP0eOWXNVyydFafygsaCFufysI9F/s1600/Screen+Shot+2017-08-23+at+2.26.32+AM.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;310&quot; data-original-width=&quot;866&quot; height=&quot;142&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgzXpI4FyRX4uQEczzdBmsy7U1klpbC-0WGhAr8t372jMMzAMY-vXntU6P4T5fp3EaOHGTWK1Y4p8NtgYe6-lBQ0sdujWJaNFh9bYLf2PizvldfAf13EP0eOWXNVyydFafygsaCFufysI9F/s400/Screen+Shot+2017-08-23+at+2.26.32+AM.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;- Arshpreet Wadehra
http://twitter.com/wadehrarshpreet&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cplspls.blogspot.com/feeds/5803739539618071184/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://cplspls.blogspot.com/2017/08/check-given-string-for-palindrome.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7607138261163784346/posts/default/5803739539618071184'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7607138261163784346/posts/default/5803739539618071184'/><link rel='alternate' type='text/html' href='http://cplspls.blogspot.com/2017/08/check-given-string-for-palindrome.html' title='Check given String for Palindrome'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgzXpI4FyRX4uQEczzdBmsy7U1klpbC-0WGhAr8t372jMMzAMY-vXntU6P4T5fp3EaOHGTWK1Y4p8NtgYe6-lBQ0sdujWJaNFh9bYLf2PizvldfAf13EP0eOWXNVyydFafygsaCFufysI9F/s72-c/Screen+Shot+2017-08-23+at+2.26.32+AM.png" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7607138261163784346.post-8716708887591830206</id><published>2016-12-05T10:47:00.001-08:00</published><updated>2016-12-05T10:47:52.285-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Programs"/><title type='text'>Program: Print first 10 Perfect Number</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;b&gt;Program: Find or Print first 10 Perfect Number&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;/span&gt; &lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;b&gt;Perfect number &lt;/b&gt;is a positive number which sum of all positive divisors excluding that number.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;For example: 6 is perfect number as divisor of 6 are 1, 2, 3. Sum of it divisor is 1&amp;nbsp;+ 2&amp;nbsp;+ 3 = 6.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;color: #333333; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;Simple way to do is find divisor of each element and check for perfect number. But it is slow as it take more time.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;So there is general way to find perfect number as given in &lt;a href=&quot;https://en.wikipedia.org/wiki/Perfect_number#Even_perfect_numbers&quot; target=&quot;_blank&quot;&gt;wikipedia&lt;/a&gt;, perfect number exist only for even number. It is given by&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;color: #252525;&quot;&gt;2&lt;/span&gt;&lt;sup style=&quot;color: #252525; line-height: 1;&quot;&gt;&lt;i&gt;p&lt;/i&gt;−1&lt;/sup&gt;&lt;span style=&quot;color: #252525;&quot;&gt;(2&lt;/span&gt;&lt;sup style=&quot;color: #252525; line-height: 1;&quot;&gt;&lt;i&gt;p&lt;/i&gt;&lt;/sup&gt;&lt;span style=&quot;color: #252525;&quot;&gt;&amp;nbsp;−&amp;nbsp;1) where p is a prime number&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;color: #252525;&quot;&gt;For example for p = 2 :&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;2&lt;/span&gt;&lt;sup style=&quot;color: #252525; font-family: Georgia, &amp;quot;Times New Roman&amp;quot;, serif; line-height: 1;&quot;&gt;1&lt;/sup&gt;&lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;(2&lt;/span&gt;&lt;sup style=&quot;color: #252525; font-family: Georgia, &amp;quot;Times New Roman&amp;quot;, serif; line-height: 1;&quot;&gt;&lt;i&gt;2&lt;/i&gt;&lt;/sup&gt;&lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&amp;nbsp;−&amp;nbsp;1) = 6,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;similarly for&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;color: #252525;&quot;&gt;p = 3 :&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;2&lt;/span&gt;&lt;sup style=&quot;color: #252525; font-family: Georgia, &amp;quot;Times New Roman&amp;quot;, serif; line-height: 1;&quot;&gt;2&lt;/sup&gt;&lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;(2&lt;/span&gt;&lt;sup style=&quot;color: #252525; font-family: Georgia, &amp;quot;Times New Roman&amp;quot;, serif; line-height: 1;&quot;&gt;&lt;i&gt;3&lt;/i&gt;&lt;/sup&gt;&lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&amp;nbsp;−&amp;nbsp;1) = 28 ...&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;So in this program we are printing up to 10 perfect number.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;#include &amp;lt;iostream&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;#include &amp;lt;cmath&amp;gt; &lt;/span&gt;&lt;span style=&quot;color: #6aa84f; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;//for pow function&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;using namespace std;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;bool isPrime(int n) &lt;/span&gt;&lt;span style=&quot;color: #6aa84f; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;//check prime number&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #6aa84f; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;//this snippet is taken from program: &lt;a href=&quot;http://cplspls.blogspot.com/2016/11/program-check-given-number-for-prime.html&quot; target=&quot;_blank&quot;&gt;Check given number for Prime Number&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&amp;nbsp;bool flag = true;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&amp;nbsp;if(n&amp;lt;2)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&amp;nbsp; flag = false;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&amp;nbsp;else if(n == 2)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&amp;nbsp; flag = true;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else if(n%2 ==0)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; flag = false;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&amp;nbsp;else{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&amp;nbsp; for(int i=3;i&amp;lt;n;i+=2){&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&amp;nbsp; &amp;nbsp;if(n%i == 0)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&amp;nbsp; &amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&amp;nbsp; &amp;nbsp; flag = false;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;break;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&amp;nbsp; &amp;nbsp;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&amp;nbsp;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return flag; &lt;/span&gt;&lt;span style=&quot;color: #6aa84f; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;//return boolean value&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;color: #6aa84f; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;/*&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #6aa84f; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;using above formula we made function which return the perfect number according to given prime number.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #6aa84f; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;*/&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;unsigned long long getPerfectNumber(int n){&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&amp;nbsp; &amp;nbsp; return (pow(2,n-1)*(pow(2,n)-1));&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;int main()&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #6aa84f; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;//print for prime number = 2&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #6aa84f; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;cout &amp;lt;&amp;lt; getPerfectNumber(2)&amp;lt;&amp;lt;endl;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&amp;nbsp; &amp;nbsp; for(int i =3,j=1;j&amp;lt;10;i+=2){&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(isPrime(i)){ &lt;/span&gt;&lt;span style=&quot;color: #6aa84f; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;//check prime if found then will print perfect number&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; cout &amp;lt;&amp;lt; getPerfectNumber(i)&amp;lt;&amp;lt;endl; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; j++;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&amp;nbsp; return 0; &lt;/span&gt;&lt;span style=&quot;color: #6aa84f; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;//&lt;a href=&quot;https://cplspls.blogspot.com/&quot;&gt;https://cplspls.blogspot.com&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;OUTPUT:&lt;/span&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/AVvXsEh6utj1lIYuDhaneW5AwDqj3tsPCmh98qPwM1_9_5-p_hyphenhyphenWuZMpDhwFJETJwz0nvsr6B14P6PywfHyQ0K7RKh4Fx4Mb4ooi1eieHD09i1rr4Ue9QEdWMB-ciAmgWZUxFTwk2nceLy2FKIbe/s1600/perfect.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh6utj1lIYuDhaneW5AwDqj3tsPCmh98qPwM1_9_5-p_hyphenhyphenWuZMpDhwFJETJwz0nvsr6B14P6PywfHyQ0K7RKh4Fx4Mb4ooi1eieHD09i1rr4Ue9QEdWMB-ciAmgWZUxFTwk2nceLy2FKIbe/s1600/perfect.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style=&quot;color: #252525; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;br /&gt;
For those who want to do by simple way by check each number for perfect number then here is program:-&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
using namespace std;&lt;br /&gt;
&lt;br /&gt;
int main() {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;unsigned long long sum;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; int n = 4; &lt;span style=&quot;color: #6aa84f;&quot;&gt;//number of perfect number to print&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;for(int i=2,j=0;j&amp;lt;n;i++){&lt;span style=&quot;color: #6aa84f;&quot;&gt;//we start from 2 and start checking each number&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;sum = 0;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;for(int j=1;j&amp;lt;i;j++){ &lt;span style=&quot;color: #6aa84f;&quot;&gt;//find divisor&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;if(i%j == 0)&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;sum+=j; &lt;span style=&quot;color: #6aa84f;&quot;&gt;//add divisor&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;if(sum == i){ &lt;span style=&quot;color: #6aa84f;&quot;&gt;//compare sum with number&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;cout &amp;lt;&amp;lt; sum&amp;lt;&amp;lt;endl;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;j++;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Above program sure look small as compare to above one but time taken to print 10 elements will take a lot of time and memory while first code will give answer within few seconds.&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;- Arshpreet Wadehra
http://twitter.com/wadehrarshpreet&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cplspls.blogspot.com/feeds/8716708887591830206/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://cplspls.blogspot.com/2016/12/program-print-first-10-perfect-number.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7607138261163784346/posts/default/8716708887591830206'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7607138261163784346/posts/default/8716708887591830206'/><link rel='alternate' type='text/html' href='http://cplspls.blogspot.com/2016/12/program-print-first-10-perfect-number.html' title='Program: Print first 10 Perfect Number'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh6utj1lIYuDhaneW5AwDqj3tsPCmh98qPwM1_9_5-p_hyphenhyphenWuZMpDhwFJETJwz0nvsr6B14P6PywfHyQ0K7RKh4Fx4Mb4ooi1eieHD09i1rr4Ue9QEdWMB-ciAmgWZUxFTwk2nceLy2FKIbe/s72-c/perfect.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7607138261163784346.post-7404538585904262582</id><published>2016-12-01T00:30:00.000-08:00</published><updated>2016-12-01T00:30:22.342-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Programs"/><title type='text'>Program: Print first n Prime Number</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;Program: Print first n Prime Number&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/b&gt; &lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;We earlier done the program of how to check &lt;a href=&quot;https://cplspls.blogspot.com/2016/11/program-check-given-number-for-prime.html&quot; target=&quot;_blank&quot;&gt;Prime Number&lt;/a&gt;, in that program we are checking whether the given number is prime or not.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;In this program we are taking input n and printing first n prime number.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif; font-size: 15px;&quot;&gt;Prime number is a number which is greater than one and can only divide by 1 or by its own number.&lt;/span&gt;&lt;/blockquote&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;#include &amp;lt;iostream&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;using namespace std;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;//we already discuss about how to check prime number so we create a &lt;a href=&quot;https://cplspls.blogspot.com/2016/11/introduction-to-user-defined-functions.html&quot; target=&quot;_blank&quot;&gt;function&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;a href=&quot;https://cplspls.blogspot.com/2011/12/program-using-bool-data-type.html&quot; target=&quot;_blank&quot;&gt;bool&lt;/a&gt; &lt;a href=&quot;https://cplspls.blogspot.com/2011/12/program-using-bool-data-type.html&quot; target=&quot;_blank&quot;&gt;isPrime&lt;/a&gt;(int n)&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #6aa84f;&quot;&gt;//this snippet is taken from &lt;a href=&quot;https://cplspls.blogspot.com/2016/11/program-check-given-number-for-prime.html&quot; target=&quot;_blank&quot;&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;program:&amp;nbsp;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif; font-style: inherit; font-weight: inherit;&quot;&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&lt;a href=&quot;https://cplspls.blogspot.com/2016/11/program-check-given-number-for-prime.html&quot; target=&quot;_blank&quot;&gt;Check given number for Prime Number&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;bool flag = true;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;font-family: georgia, &amp;quot;times new roman&amp;quot;, serif; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: georgia, &amp;quot;times new roman&amp;quot;, serif;&quot;&gt;if(n&amp;lt;2)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; flag = false;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;else if(n == 2)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;flag = true;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else if(n%2 ==0)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; flag = false;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;else{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;for(int i=3;i&amp;lt;n;i+=2){&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;if(n%i == 0)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt; flag = false;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt; &amp;nbsp;break;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return flag; &lt;span style=&quot;color: #6aa84f;&quot;&gt;//return boolean value&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;int main()&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;&amp;nbsp; int n,i;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;&amp;nbsp; cout &amp;lt;&amp;lt; &quot;Enter value of n : &quot;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;&amp;nbsp; cin &amp;gt;&amp;gt; n; &lt;span style=&quot;color: #6aa84f;&quot;&gt;//input n&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Georgia, &amp;quot;Times New Roman&amp;quot;, serif;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;if(n&amp;gt;1)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;&amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;&amp;nbsp; &amp;nbsp;cout &amp;lt;&amp;lt; &quot;2 &quot;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;&amp;nbsp; &amp;nbsp;n--;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;&amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Georgia, &amp;quot;Times New Roman&amp;quot;, serif;&quot;&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;/*&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Georgia, &amp;quot;Times New Roman&amp;quot;, serif;&quot;&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;we print first prime number i.e. 2 earlier to increase the speed of program as i discussed earlier in my last program that 2 is only even prime number. Rest of prime number are odd. So we have to print 2 earlier to run loop with increment of two. This way it checks less number of number and increase its speed.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Georgia, &amp;quot;Times New Roman&amp;quot;, serif;&quot;&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;Now loop run till n value drop to zero that each value we print will decrement value of n. So we can print exactly n number only.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Georgia, &amp;quot;Times New Roman&amp;quot;, serif;&quot;&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;In loop we pick number and check whether it is prime or not from function which return true or false. According to result we print the prime number or not.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Georgia, &amp;quot;Times New Roman&amp;quot;, serif;&quot;&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;&amp;nbsp; for(i=2;n&amp;gt;0;i+=2)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;&amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; if(isPrime(i))&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; cout &amp;lt;&amp;lt; i &amp;lt;&amp;lt; &quot; &quot;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; n--;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;&amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;&amp;nbsp; return 0; // &lt;a href=&quot;https://cplspls.blogspot.com/&quot;&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;https://cplspls.blogspot.com&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;OUTPUT:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-lg8LiG2EoTPox55zeWepHqQC48eKokZhbuKBCOMqNgSrWiRXd_cGSjameFLPNIMNUit85bwxobjLpBrCqs3bZy-ulzl7NrQjkIVaXLNbP9hX6dKI8DqgLA91qq7-oTWgTMuzrAy6AsbW/s1600/prim.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em; text-align: center;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-lg8LiG2EoTPox55zeWepHqQC48eKokZhbuKBCOMqNgSrWiRXd_cGSjameFLPNIMNUit85bwxobjLpBrCqs3bZy-ulzl7NrQjkIVaXLNbP9hX6dKI8DqgLA91qq7-oTWgTMuzrAy6AsbW/s1600/prim.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;- Arshpreet Wadehra
http://twitter.com/wadehrarshpreet&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cplspls.blogspot.com/feeds/7404538585904262582/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://cplspls.blogspot.com/2016/12/program-print-first-n-prime-number.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7607138261163784346/posts/default/7404538585904262582'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7607138261163784346/posts/default/7404538585904262582'/><link rel='alternate' type='text/html' href='http://cplspls.blogspot.com/2016/12/program-print-first-n-prime-number.html' title='Program: Print first n Prime Number'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-lg8LiG2EoTPox55zeWepHqQC48eKokZhbuKBCOMqNgSrWiRXd_cGSjameFLPNIMNUit85bwxobjLpBrCqs3bZy-ulzl7NrQjkIVaXLNbP9hX6dKI8DqgLA91qq7-oTWgTMuzrAy6AsbW/s72-c/prim.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7607138261163784346.post-8808865330064562590</id><published>2016-11-30T12:04:00.000-08:00</published><updated>2016-11-30T12:05:02.917-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Introduction"/><title type='text'>Introduction to User Defined Functions</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;b&gt;Introduction to User Defined Functions&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;text-align: justify;&quot;&gt;A function is a group of statements that together perform a task. Every C++ program has at least one function, which is&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;text-align: justify;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;main()&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;text-align: justify;&quot;&gt;, and all the most trivial programs can define additional functions.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt; &lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;text-align: justify;&quot;&gt;We have study about &lt;a href=&quot;https://cplspls.blogspot.com/2011/12/program-using-define-function.html&quot; target=&quot;_blank&quot;&gt;#define &lt;/a&gt;in previous lessons. Functions is similar to #define but less secure than functions as it doesn&#39;t have any return type or data type of parameters which provide certain level of data security.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt; &lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;text-align: justify;&quot;&gt;Functions usually defined because a certain snippet of code are used again and again. So instead of writing again and again we create a&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;b&gt;Function&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;text-align: justify;&quot;&gt;&lt;b style=&quot;text-align: justify;&quot;&gt;&amp;nbsp;&lt;/b&gt;&lt;span style=&quot;text-align: justify;&quot;&gt;which stores the required statement to execute and it may return result according to return type.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt; &lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;Functions are used to provide modularity to a program. Creating an application using function makes it easier to understand, edit, check errors etc.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;A function is also known as method or a sub-routine or procedure etc.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;Syntax of Function&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;return-type function-name (parameters){&lt;br /&gt; &amp;nbsp; &amp;nbsp;// function-body&lt;br /&gt;}&lt;/span&gt;&lt;/blockquote&gt;
&lt;div style=&quot;box-sizing: border-box; line-height: 24px; margin: 0em 0.2em 1em; padding: 0px; text-align: justify; word-wrap: break-word;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;A C++ function definition consists of a function header and a function body. Here are all the parts of a function:&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;box-sizing: border-box; text-align: justify;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;ul&gt;&lt;span style=&quot;box-sizing: border-box; text-align: justify;&quot;&gt;
&lt;li&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;Return-Type&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;b&gt;: &lt;/b&gt;The&amp;nbsp;&lt;span style=&quot;box-sizing: border-box;&quot;&gt;return-type&lt;/span&gt;&amp;nbsp;is the data type of the value the function returns. return-type can be of any data type or user defined type also. It can be void when we don&#39;t have to return anything.&lt;/span&gt;&lt;/li&gt;
&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;
&lt;li&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;&lt;b style=&quot;box-sizing: border-box;&quot;&gt;Function Name:&lt;/b&gt;&amp;nbsp;&lt;/span&gt;The function-name is name of function through which we gonna call it.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;&lt;b style=&quot;box-sizing: border-box;&quot;&gt;Parameters:&lt;/b&gt;&amp;nbsp;&lt;/span&gt;A parameter is like a placeholder. When a function is invoked, you pass a value to the parameter. This value is referred to as actual parameter or argument. The parameter list refers to the type, order, and number of the parameters of a function. Parameters are optional; that is, a function may contain no parameters. Parameters are also known as Function Signature.&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;&lt;b style=&quot;box-sizing: border-box;&quot;&gt;Function Body:&lt;/b&gt;&amp;nbsp;&lt;/span&gt;The function body contains a collection of statements that define what the function does.&lt;/li&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/ul&gt;
&lt;span style=&quot;box-sizing: border-box; text-align: justify;&quot;&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;ul class=&quot;list&quot; style=&quot;box-sizing: border-box; color: #313131;&quot;&gt;
&lt;/ul&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;Function Declaration includes&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;return-type function-name (parameters);&lt;/span&gt;&lt;/span&gt;&lt;/blockquote&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;Function declaration is similar to function defination just without function body.&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;In C++ before calling function we must either define the function or declare the function. If we try to call function from main() and it is defined after the main() method then it will give compile error as compiler doesn&#39;t recognize the function as its not defined till now. So we need to tell compiler by declaring earlier or define the function.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&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: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;Below example contain usage of both defining and declaring the function before main method.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&amp;nbsp;Example:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;#include&amp;lt;iostream&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;using namespace std;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;void display(int x); &lt;span style=&quot;color: #6aa84f;&quot;&gt;//declaring the function&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;//define the function&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;int calculate(int x,int y) &lt;span style=&quot;color: #6aa84f;&quot;&gt;//int = data type&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #6aa84f; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;//calculate = function-name&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #6aa84f; font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;//int x, int y = function parameter or signature&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;{&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&amp;nbsp; &amp;nbsp;return x+y; &lt;span style=&quot;color: #6aa84f;&quot;&gt;//return integer type&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;int main()&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&amp;nbsp; int x = calculate(2,5);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&amp;nbsp; display(x);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&amp;nbsp; return 0; &lt;span style=&quot;color: #6aa84f;&quot;&gt;// https://cplspls.blogspot.com&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;void display(int x) &lt;span style=&quot;color: #6aa84f;&quot;&gt;//definition&amp;nbsp;of function which is declared above&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&amp;nbsp; cout &amp;lt;&amp;lt; x&amp;lt;&amp;lt;endl;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;b&gt;OUTPUT:&lt;/b&gt;&lt;/span&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/AVvXsEjIz2fRMUqGU46u-hw0XPvmVHWCtbTHfBet1RM1KVZ0frwxJzcu6sE8g8gmQFMReR5p9_cXur9Bk4XfUVYDI9ajPyrmdftHtVTdd31PPcWk_3a7yD8a31os_oFBLnEpctaVYLpeFzeWwCJz/s1600/7.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;b&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIz2fRMUqGU46u-hw0XPvmVHWCtbTHfBet1RM1KVZ0frwxJzcu6sE8g8gmQFMReR5p9_cXur9Bk4XfUVYDI9ajPyrmdftHtVTdd31PPcWk_3a7yD8a31os_oFBLnEpctaVYLpeFzeWwCJz/s1600/7.png&quot; /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;georgia&amp;quot; , &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;- Arshpreet Wadehra
http://twitter.com/wadehrarshpreet&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cplspls.blogspot.com/feeds/8808865330064562590/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://cplspls.blogspot.com/2016/11/introduction-to-user-defined-functions.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7607138261163784346/posts/default/8808865330064562590'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7607138261163784346/posts/default/8808865330064562590'/><link rel='alternate' type='text/html' href='http://cplspls.blogspot.com/2016/11/introduction-to-user-defined-functions.html' title='Introduction to User Defined Functions'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIz2fRMUqGU46u-hw0XPvmVHWCtbTHfBet1RM1KVZ0frwxJzcu6sE8g8gmQFMReR5p9_cXur9Bk4XfUVYDI9ajPyrmdftHtVTdd31PPcWk_3a7yD8a31os_oFBLnEpctaVYLpeFzeWwCJz/s72-c/7.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7607138261163784346.post-6569469489481947755</id><published>2016-11-30T02:59:00.000-08:00</published><updated>2016-11-30T02:59:09.898-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Programs"/><title type='text'>Program: Check given number for Prime Number</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;Program: Check given number for Prime Number&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;We know about prime number is a number which is greater than one and can only divide by 1 or by its own number. In this program we check the given number for prime number.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;#include &amp;lt;iostream&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;using namespace std;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;int main() {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;int n;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;cout &amp;lt;&amp;lt; &quot;Enter Prime Number: &quot;;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; cin &amp;gt;&amp;gt; n;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: Georgia, &amp;quot;Times New Roman&amp;quot;, serif;&quot;&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;//input number&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;//initialize&amp;nbsp;flag for true assume given number is prime number&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;bool flag = true;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;//if number is less than 2 than its not a prime number according to def&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;font-family: Georgia, &amp;quot;Times New Roman&amp;quot;, serif; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: Georgia, &amp;quot;Times New Roman&amp;quot;, serif;&quot;&gt;if(n&amp;lt;2)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; flag = false;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;font-family: Georgia, &amp;quot;Times New Roman&amp;quot;, serif; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: Georgia, &amp;quot;Times New Roman&amp;quot;, serif;&quot;&gt;else if(n == 2) &lt;span style=&quot;color: #6aa84f;&quot;&gt;// if n is 2 than its prime number&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;flag = true;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else if(n%2 ==0)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; flag = false;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;else{&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #6aa84f; font-family: Georgia, Times New Roman, serif;&quot;&gt;/*&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #6aa84f; font-family: Georgia, Times New Roman, serif;&quot;&gt;&amp;nbsp; &amp;nbsp;Now we check n &amp;gt; 2 whether its prime or not. We check for 2 earlier because from now on we are gonna skip all even number as other than 2 there are no even prime number as all divisible by 2. So we start with 3&amp;nbsp;and check up to&amp;nbsp;n with increment of two in one loop. So if any number less than n found divisible with n then set flag to false and break the loop.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #6aa84f; font-family: Georgia, Times New Roman, serif;&quot;&gt;*/&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;for(int i=3;i&amp;lt;n;i+=2){&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;if(n%i == 0)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt; flag = false;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt; &amp;nbsp;break;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #6aa84f; font-family: Georgia, Times New Roman, serif;&quot;&gt;//print output according to flag value&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;if(flag)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;cout&amp;lt;&amp;lt;&quot;It is a Prime Number&quot;;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;else&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;cout&amp;lt;&amp;lt;&quot;It is Not a Prime Number&quot;;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;return 0; &amp;nbsp;&lt;span style=&quot;color: #6aa84f;&quot;&gt;//https://cplspls.blogspot.com&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Georgia, &amp;quot;Times New Roman&amp;quot;, serif;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Georgia, &amp;quot;Times New Roman&amp;quot;, serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Georgia, &amp;quot;Times New Roman&amp;quot;, serif;&quot;&gt;&lt;b&gt;OUTPUT:&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Georgia, &amp;quot;Times New Roman&amp;quot;, serif;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEicqSTFfohaVOB52QQ4qI0EMQMNQrhz__pUlDZoUwGJS5FGi8_3J-Z2xgoJR8dbhf1eo0rZ2-3LZdQ2hS24k3lW5U_AR1qw-nt_zmu-sjSOahSi_upBGaUwHwk6PEuQt8dlISp5loYGUosF/s1600/cpp0.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEicqSTFfohaVOB52QQ4qI0EMQMNQrhz__pUlDZoUwGJS5FGi8_3J-Z2xgoJR8dbhf1eo0rZ2-3LZdQ2hS24k3lW5U_AR1qw-nt_zmu-sjSOahSi_upBGaUwHwk6PEuQt8dlISp5loYGUosF/s1600/cpp0.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Georgia, &amp;quot;Times New Roman&amp;quot;, serif;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;- Arshpreet Wadehra
http://twitter.com/wadehrarshpreet&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cplspls.blogspot.com/feeds/6569469489481947755/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://cplspls.blogspot.com/2016/11/program-check-given-number-for-prime.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7607138261163784346/posts/default/6569469489481947755'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7607138261163784346/posts/default/6569469489481947755'/><link rel='alternate' type='text/html' href='http://cplspls.blogspot.com/2016/11/program-check-given-number-for-prime.html' title='Program: Check given number for Prime Number'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEicqSTFfohaVOB52QQ4qI0EMQMNQrhz__pUlDZoUwGJS5FGi8_3J-Z2xgoJR8dbhf1eo0rZ2-3LZdQ2hS24k3lW5U_AR1qw-nt_zmu-sjSOahSi_upBGaUwHwk6PEuQt8dlISp5loYGUosF/s72-c/cpp0.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7607138261163784346.post-3049834825688860721</id><published>2015-12-12T08:10:00.002-08:00</published><updated>2015-12-12T08:12:41.131-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Introduction"/><title type='text'>Use of goto Statement</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;b style=&quot;font-size: x-large;&quot;&gt;Using goto Statement&lt;/b&gt;&lt;br /&gt;
&lt;b style=&quot;font-size: x-large;&quot;&gt;&lt;br /&gt;
&lt;/b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;goto statement is used to jump on a particular location in a program defined by label. Label is a name given to a location.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Label is defined by a &amp;lt;locationName&amp;gt; followed by a colon.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;goto is use with goto &amp;lt;labelName&amp;gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;font-size: large;&quot;&gt;syntax of label &amp;amp; goto&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;font-size: large;&quot;&gt;statment 1;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;label: &lt;span style=&quot;color: #6aa84f;&quot;&gt;//syntax of label&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;statment 2;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;statment 3;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;if(statement) &lt;span style=&quot;color: #6aa84f;&quot;&gt;//if condition true&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;goto label;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;//jump to label i.e. after statement 1 and program will execute again statement 2 and 3&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;font-size: large;&quot;&gt;Let Check out Example for better understanding&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span id=&quot;ex1&quot; style=&quot;font-size: large;&quot;&gt;Ex1: Print first 10 Natural Number&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-size: medium;&quot;&gt;#include&amp;lt;iostream.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-size: medium;&quot;&gt;int main()&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-size: medium;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-size: medium;&quot;&gt;&amp;nbsp; &amp;nbsp; int i=1;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-size: medium;&quot;&gt;&amp;nbsp; &amp;nbsp; print:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-size: medium;&quot;&gt;&amp;nbsp; &amp;nbsp; cout &amp;lt;&amp;lt; i &amp;lt;&amp;lt;endl;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-size: medium;&quot;&gt;&amp;nbsp; &amp;nbsp; if(i&amp;lt;10)&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-size: medium;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-size: medium;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; i++;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-size: medium;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; goto print; &lt;/span&gt;&lt;span style=&quot;color: #38761d; font-size: medium;&quot;&gt;//jump to print label as define above after&amp;nbsp;initialization&amp;nbsp;of i&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-size: medium;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #6aa84f; font-size: medium;&quot;&gt;/*&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #6aa84f; font-size: medium;&quot;&gt;In Above Program we are printing first 10 natural number using goto statment&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #6aa84f; font-size: medium;&quot;&gt;in this example goto is used as loop to print 1 to 10&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #6aa84f; font-size: medium;&quot;&gt;first we initialize the variable i to 1&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #6aa84f; font-size: medium;&quot;&gt;then we define a checkpoint or label for using with goto&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #6aa84f; font-size: medium;&quot;&gt;then we print value of variable i&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #6aa84f; font-size: medium;&quot;&gt;we check if variable i is less than 10 if true then increment of variable i and jump to checkpoint or label we define earlier to print again this process continue till condition is false similar in a loop&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #6aa84f; font-size: medium;&quot;&gt;*/&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-size: medium;&quot;&gt;&amp;nbsp;return 0;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-size: medium;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;background-color: #fafafa; color: #333333; font-size: medium;&quot;&gt;OUTPUT&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #fafafa; color: #333333; font-size: medium;&quot;&gt;&lt;br /&gt;
&lt;/span&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/AVvXsEiDvYcEvf2b3copWH1D9hPwxwvWjK50oHISfafThyphenhyphenfk9MS7q454-oDS9ne4iHULFVAKuhqEPCVLXtyr-zARwtQbgOd_bQi7BGjiy2cJVMp9jfDCmG5uOB5GQyqJNN-LqkQONHYoU0ko8Dy-/s1600/goto.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;199&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiDvYcEvf2b3copWH1D9hPwxwvWjK50oHISfafThyphenhyphenfk9MS7q454-oDS9ne4iHULFVAKuhqEPCVLXtyr-zARwtQbgOd_bQi7BGjiy2cJVMp9jfDCmG5uOB5GQyqJNN-LqkQONHYoU0ko8Dy-/s320/goto.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;span style=&quot;background-color: #fafafa; color: #333333; font-size: medium;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;background-color: #fafafa; color: #333333; font-size: medium;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span id=&quot;ex2&quot; style=&quot;font-size: large;&quot;&gt;Ex2: Divide Two Numbers&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;a href=&quot;http://cplspls.blogspot.in/2015/12/continue.html#ex2&quot; target=&quot;_blank&quot;&gt;[check this program using loop]&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-size: medium;&quot;&gt;#include&amp;lt;iostream.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-size: medium;&quot;&gt;int main()&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-size: medium;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #6aa84f; font-size: medium;&quot;&gt;//Divide Two Numbers&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-size: medium;&quot;&gt;&amp;nbsp; &amp;nbsp; char ch;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-size: medium;&quot;&gt;&amp;nbsp; &amp;nbsp; float a,b;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-size: medium;&quot;&gt;&amp;nbsp; &amp;nbsp; tryAgain:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-size: medium;&quot;&gt;&amp;nbsp; &amp;nbsp; cout &amp;lt;&amp;lt; &quot;Enter First Number : &quot;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-size: medium;&quot;&gt;&amp;nbsp; &amp;nbsp; cin &amp;gt;&amp;gt; a; //Input First Number&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-size: medium;&quot;&gt;&amp;nbsp; &amp;nbsp; cout &amp;lt;&amp;lt; &quot;Enter Second Number : &quot;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-size: medium;&quot;&gt;&amp;nbsp; &amp;nbsp; cin &amp;gt;&amp;gt; b; //Input Second Number&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-size: medium;&quot;&gt;&amp;nbsp; &amp;nbsp; if(b == 0) // Check for divisor for zero&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-size: medium;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-size: medium;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; cout &amp;lt;&amp;lt; &quot;Error: Number Cannot Divide by Zero&quot;&amp;lt;&amp;lt;endl; //return error message&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-size: medium;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; goto tryAgain;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-size: medium;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-size: medium;&quot;&gt;&amp;nbsp; &amp;nbsp; cout &amp;lt;&amp;lt; &quot;Answer = &quot; &amp;lt;&amp;lt; a/b&amp;lt;&amp;lt;endl;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-size: medium;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;color: #333333; font-size: medium;&quot;&gt;&amp;nbsp; &amp;nbsp; cout &amp;lt;&amp;lt; &quot;Try Again(y/n): &quot;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-size: medium;&quot;&gt;&amp;nbsp; &amp;nbsp; if(cin &amp;gt;&amp;gt; ch &amp;amp;&amp;amp; ch != &#39;n&#39;)&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-size: medium;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; goto tryAgain;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-size: medium;&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #93c47d; font-size: medium;&quot;&gt;/*&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #93c47d; font-size: medium;&quot;&gt;In this example we are dividing two number and check for divisor not equal to zero&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #93c47d; font-size: medium;&quot;&gt;first we define label before taking input from user&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #93c47d; font-size: medium;&quot;&gt;then we take input two numbers&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #93c47d; font-size: medium;&quot;&gt;if (divisor(here b) = 0) then print error message and goto label; that jump back to a point where we have to take input again&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #93c47d; font-size: medium;&quot;&gt;now if divisor is not zero then we print answer and ask user for more&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #93c47d; font-size: medium;&quot;&gt;here you can see expression in if condition&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #93c47d; font-size: medium;&quot;&gt;if(cin&amp;gt;&amp;gt; ch &amp;amp;&amp;amp; ch != &#39;n&#39;)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #93c47d; font-size: medium;&quot;&gt;above if statement has two conditions for check as there is AND(&amp;amp;&amp;amp;) between them means both must be true&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #93c47d; font-size: medium;&quot;&gt;check each conditions cin &amp;gt;&amp;gt; ch this will return true when it take input successfully&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #93c47d; font-size: medium;&quot;&gt;and then it compare ch != &#39;n&#39;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #93c47d; font-size: medium;&quot;&gt;means here we are do two operation that first we take input and check for equality in one statement&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #93c47d; font-size: medium;&quot;&gt;second condition will run only when we get input from first statement&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #93c47d; font-size: medium;&quot;&gt;so if its true then it goto label;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #93c47d; font-size: medium;&quot;&gt;else &amp;lt;end of program&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #93c47d; font-size: medium;&quot;&gt;*/&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-size: medium;&quot;&gt;&amp;nbsp; &amp;nbsp; return 0;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-size: medium;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: medium;&quot;&gt;&lt;span style=&quot;background-color: #fafafa;&quot;&gt;Output&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: medium;&quot;&gt;&lt;span style=&quot;background-color: #fafafa;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div&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/AVvXsEiMayVeq58n6iu32Xrbe031e3yvAXBAjacL5ytaioj9veIXWR8q8b5FmnbzCr06OfFvQmOm_G9ueQK0H38i8CCUBWew1SRhyphenhyphenfuxYc84whb3HqelsARqvBjKaHBg096WaTuJVKcXWivTzTOx/s1600/continue2.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;139&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMayVeq58n6iu32Xrbe031e3yvAXBAjacL5ytaioj9veIXWR8q8b5FmnbzCr06OfFvQmOm_G9ueQK0H38i8CCUBWew1SRhyphenhyphenfuxYc84whb3HqelsARqvBjKaHBg096WaTuJVKcXWivTzTOx/s320/continue2.png&quot; style=&quot;cursor: move;&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;- Arshpreet Wadehra
http://twitter.com/wadehrarshpreet&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cplspls.blogspot.com/feeds/3049834825688860721/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://cplspls.blogspot.com/2015/12/goto.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7607138261163784346/posts/default/3049834825688860721'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7607138261163784346/posts/default/3049834825688860721'/><link rel='alternate' type='text/html' href='http://cplspls.blogspot.com/2015/12/goto.html' title='Use of goto Statement'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiDvYcEvf2b3copWH1D9hPwxwvWjK50oHISfafThyphenhyphenfk9MS7q454-oDS9ne4iHULFVAKuhqEPCVLXtyr-zARwtQbgOd_bQi7BGjiy2cJVMp9jfDCmG5uOB5GQyqJNN-LqkQONHYoU0ko8Dy-/s72-c/goto.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7607138261163784346.post-1631908067516406435</id><published>2015-12-11T12:48:00.000-08:00</published><updated>2015-12-12T08:11:16.985-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Introduction"/><title type='text'>Use of Continue Statement</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;b style=&quot;font-size: x-large;&quot;&gt;Using Continue Statement&lt;/b&gt;&lt;br /&gt;
&lt;b style=&quot;font-size: x-large;&quot;&gt;&lt;br /&gt;
&lt;/b&gt; &lt;span style=&quot;font-size: large;&quot;&gt;Continue statement is used to skip the current iteration and force to execute next iteration by skipping any code after continue statement inside a loop.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;In simple term whenever you encounter continue statement in a loop it will skip the current pass execute next pass and also it skip the other statement below the continue statement inside a loop.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;font-size: large;&quot;&gt;Let check the following examples for better understanding:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;font-size: large;&quot; id=&quot;ex1&quot;&gt;Ex1: Print Odd Number&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #fafafa; color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: medium;&quot;&gt;#include&amp;lt;iostream.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #fafafa; color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: medium;&quot;&gt;int main()&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #fafafa; color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: medium;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #fafafa; color: #6aa84f; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: medium; line-height: 19.6px;&quot;&gt;//Print odd number&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #fafafa; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: medium; line-height: 19.6px;&quot;&gt;for(int i=1; i&amp;lt;=10;i++)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #fafafa; color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: medium;&quot;&gt;&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #fafafa; color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: medium;&quot;&gt;&amp;nbsp; &amp;nbsp; if(i%2==0)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #fafafa; color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: medium;&quot;&gt;&amp;nbsp; &amp;nbsp; continue;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #fafafa; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: medium;&quot;&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;/*&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #6aa84f; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: medium;&quot;&gt;&lt;span style=&quot;background-color: #fafafa;&quot;&gt;&amp;nbsp;Above two lines first line check if i is even or not, If its even then i%2 return zero&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #6aa84f; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: medium;&quot;&gt;&lt;span style=&quot;background-color: #fafafa;&quot;&gt;means condition is true for even number of i then continue statement will execute.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #6aa84f; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: medium;&quot;&gt;&lt;span style=&quot;background-color: #fafafa;&quot;&gt;As you can see in output we are printing only odd numbers so whenever continue statement runs it will skip all next line inside a loop and go to next iteration that increment of i&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #fafafa; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: medium;&quot;&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #fafafa; color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: medium;&quot;&gt;&amp;nbsp; &amp;nbsp; cout &amp;lt;&amp;lt; i&amp;lt;&amp;lt;endl;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #fafafa; color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: medium;&quot;&gt;&amp;nbsp;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #fafafa; color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: medium;&quot;&gt;return 0;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #fafafa; color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: medium;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #fafafa; color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: medium;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;background-color: #fafafa; color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: medium;&quot;&gt;OUTPUT&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #fafafa; color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: medium;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://1.bp.blogspot.com/mZhfk04V6I1iHbVcVD213oKqTbXF5abFYMP30C0vb4hcf4kxcUpCJLAf95CU72Yh8S3aLSr8T8ciSIVp52DMCvY2CND0dvFrOgIMqjbfh90_tJvPnVZTkfdvQY2t2b50twOsQO-48sHkLzlo4sEuVjXZhYl4rYanhbDxHqUxI46iIY8Ozx4lHqBFEFFWQWGtyXNK4H7X2cKc20QgVTt1XCE50xXD0MDY2RDHvjdD1N25dYfKx_qHhMGGHyjN_ouTuI5TU86DE0tEgSSDlb8AYTqZ4QazYptPJeHO8rvfgYRe82TVFcNmxoBL2MkAG0zhm1zaU66pO1LeCcbhUuYroAfEGFATT63xCESp4x31ASMsN1u2XXiW4UwUHbCaPAQauvDIuFTslQbi-MmTjSexudTiMJjoyWOWWdlAj42P1OBuWO6XvfdchmSSDrDvFCVa0B23Ak5_rMyFDI1xmnfP6vaELMJ-fxhS-OMQ4qforCs4y5peN5cZkvc5hfs9LN4Reus6N5sP8o46yQWKI8gDafXhAcL67-sBiHqT4gFSLysNGFotLBTOOg-5hDAq48A=w271-h115-no&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://1.bp.blogspot.com/mZhfk04V6I1iHbVcVD213oKqTbXF5abFYMP30C0vb4hcf4kxcUpCJLAf95CU72Yh8S3aLSr8T8ciSIVp52DMCvY2CND0dvFrOgIMqjbfh90_tJvPnVZTkfdvQY2t2b50twOsQO-48sHkLzlo4sEuVjXZhYl4rYanhbDxHqUxI46iIY8Ozx4lHqBFEFFWQWGtyXNK4H7X2cKc20QgVTt1XCE50xXD0MDY2RDHvjdD1N25dYfKx_qHhMGGHyjN_ouTuI5TU86DE0tEgSSDlb8AYTqZ4QazYptPJeHO8rvfgYRe82TVFcNmxoBL2MkAG0zhm1zaU66pO1LeCcbhUuYroAfEGFATT63xCESp4x31ASMsN1u2XXiW4UwUHbCaPAQauvDIuFTslQbi-MmTjSexudTiMJjoyWOWWdlAj42P1OBuWO6XvfdchmSSDrDvFCVa0B23Ak5_rMyFDI1xmnfP6vaELMJ-fxhS-OMQ4qforCs4y5peN5cZkvc5hfs9LN4Reus6N5sP8o46yQWKI8gDafXhAcL67-sBiHqT4gFSLysNGFotLBTOOg-5hDAq48A=w271-h115-no&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;span style=&quot;background-color: #fafafa; color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: medium;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;background-color: #fafafa; color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: medium;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;background-color: #fafafa; color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: medium;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;font-size: large;&quot; id=&quot;ex2&quot;&gt;Ex2: Divide Two Numbers&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #fafafa; color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: medium;&quot;&gt;#include&amp;lt;iostream.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #fafafa; color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: medium;&quot;&gt;int main()&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #fafafa; color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: medium;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #fafafa; color: #6aa84f; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: medium; line-height: 19.6px;&quot;&gt;//Divide Two Numbers&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #fafafa; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: medium; line-height: 19.6px;&quot;&gt;char ch;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #fafafa; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: medium; line-height: 19.6px;&quot;&gt;float a,b;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #fafafa; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: medium; line-height: 19.6px;&quot;&gt;do&lt;span style=&quot;color: #6aa84f;&quot;&gt; //Using &lt;a href=&quot;http://cplspls.blogspot.in/2012/01/introduction-to-loop.html&quot; target=&quot;_blank&quot;&gt;Do While Loop&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #fafafa; color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: medium;&quot;&gt;&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #fafafa; color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: medium;&quot;&gt;&amp;nbsp; cout &amp;lt;&amp;lt; &quot;Enter First Number : &quot;;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #fafafa; color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: medium;&quot;&gt;&amp;nbsp; cin &amp;gt;&amp;gt; a; &lt;/span&gt;&lt;span style=&quot;background-color: #fafafa; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: medium;&quot;&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;//Input First Number&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;background-color: #fafafa; color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: medium;&quot;&gt;&amp;nbsp; cout &amp;lt;&amp;lt; &quot;Enter Second Number : &quot;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #fafafa; color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: medium;&quot;&gt;&amp;nbsp; cin &amp;gt;&amp;gt; b; &lt;/span&gt;&lt;span style=&quot;background-color: #fafafa; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: medium;&quot;&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;//Input Second Number&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: #fafafa; color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: medium;&quot;&gt;&amp;nbsp; if(b == 0) &lt;/span&gt;&lt;span style=&quot;background-color: #fafafa; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: medium;&quot;&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;// Check for divisor for zero&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: #fafafa; color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: medium;&quot;&gt;&amp;nbsp; &amp;nbsp;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: #fafafa; color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: medium;&quot;&gt;&amp;nbsp; &amp;nbsp; cout &amp;lt;&amp;lt; &quot;Error: Number Cannot Divide by Zero&quot;&amp;lt;&amp;lt;endl; &lt;/span&gt;&lt;span style=&quot;background-color: #fafafa; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: medium;&quot;&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;//return error message&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: #fafafa; color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: medium;&quot;&gt;&amp;nbsp; &amp;nbsp; continue;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: #fafafa; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: medium;&quot;&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;/*&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: #fafafa; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: medium;&quot;&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;In this whenever we encounter with divisor = 0 then error message is display&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: #fafafa; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: medium;&quot;&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;and continue statement will execute. Whenever Continue statement runs it will skip all the code after that inside a loop and start from next iteration. As in this example we are using Do while loop which check condition at the end but we already skip the statements after continue so we will don&#39;t check the condition and we will start loop from begin. As you can seen in Output&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: #fafafa; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: medium;&quot;&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: #fafafa; color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: medium;&quot;&gt;&amp;nbsp; &amp;nbsp;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: #fafafa; color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: medium;&quot;&gt;&amp;nbsp; cout &amp;lt;&amp;lt; &quot;Answer = &quot; &amp;lt;&amp;lt; a/b&amp;lt;&amp;lt;endl;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: #fafafa; color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: medium;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: #fafafa; color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: medium;&quot;&gt;&amp;nbsp; cout &amp;lt;&amp;lt; &quot;Try Again(y/n): &quot;;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: #fafafa; color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: medium;&quot;&gt;&amp;nbsp; cin &amp;gt;&amp;gt; ch;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;background-color: #fafafa; color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: medium;&quot;&gt;&amp;nbsp;}while(ch != &#39;n&#39;);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #fafafa; color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: medium;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;background-color: #fafafa; color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: medium;&quot;&gt;&amp;nbsp;return 0;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;background-color: #fafafa; color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: medium;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: medium;&quot;&gt;&lt;span style=&quot;background-color: #fafafa;&quot;&gt;Output&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: medium;&quot;&gt;&lt;span style=&quot;background-color: #fafafa;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMayVeq58n6iu32Xrbe031e3yvAXBAjacL5ytaioj9veIXWR8q8b5FmnbzCr06OfFvQmOm_G9ueQK0H38i8CCUBWew1SRhyphenhyphenfuxYc84whb3HqelsARqvBjKaHBg096WaTuJVKcXWivTzTOx/s1600/continue2.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;139&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMayVeq58n6iu32Xrbe031e3yvAXBAjacL5ytaioj9veIXWR8q8b5FmnbzCr06OfFvQmOm_G9ueQK0H38i8CCUBWew1SRhyphenhyphenfuxYc84whb3HqelsARqvBjKaHBg096WaTuJVKcXWivTzTOx/s320/continue2.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: medium;&quot;&gt;&lt;span style=&quot;background-color: #fafafa;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: medium;&quot;&gt;&lt;span style=&quot;background-color: #fafafa;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;- Arshpreet Wadehra
http://twitter.com/wadehrarshpreet&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cplspls.blogspot.com/feeds/1631908067516406435/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://cplspls.blogspot.com/2015/12/continue.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7607138261163784346/posts/default/1631908067516406435'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7607138261163784346/posts/default/1631908067516406435'/><link rel='alternate' type='text/html' href='http://cplspls.blogspot.com/2015/12/continue.html' title='Use of Continue Statement'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://1.bp.blogspot.com/mZhfk04V6I1iHbVcVD213oKqTbXF5abFYMP30C0vb4hcf4kxcUpCJLAf95CU72Yh8S3aLSr8T8ciSIVp52DMCvY2CND0dvFrOgIMqjbfh90_tJvPnVZTkfdvQY2t2b50twOsQO-48sHkLzlo4sEuVjXZhYl4rYanhbDxHqUxI46iIY8Ozx4lHqBFEFFWQWGtyXNK4H7X2cKc20QgVTt1XCE50xXD0MDY2RDHvjdD1N25dYfKx_qHhMGGHyjN_ouTuI5TU86DE0tEgSSDlb8AYTqZ4QazYptPJeHO8rvfgYRe82TVFcNmxoBL2MkAG0zhm1zaU66pO1LeCcbhUuYroAfEGFATT63xCESp4x31ASMsN1u2XXiW4UwUHbCaPAQauvDIuFTslQbi-MmTjSexudTiMJjoyWOWWdlAj42P1OBuWO6XvfdchmSSDrDvFCVa0B23Ak5_rMyFDI1xmnfP6vaELMJ-fxhS-OMQ4qforCs4y5peN5cZkvc5hfs9LN4Reus6N5sP8o46yQWKI8gDafXhAcL67-sBiHqT4gFSLysNGFotLBTOOg-5hDAq48A=s72-w271-h115-c-no" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7607138261163784346.post-7298542694069550</id><published>2013-10-05T01:05:00.001-07:00</published><updated>2016-11-30T12:41:50.182-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Programs"/><title type='text'>Program: Display Fibonacci Series IN C++</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;b style=&quot;color: #333333; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; line-height: 22px;&quot;&gt;Program : DISPLAY FIBONACCI SERIES IN C++&lt;/b&gt;&lt;br /&gt;
&lt;b style=&quot;color: #333333; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; line-height: 22px;&quot;&gt;&lt;br /&gt;
&lt;/b&gt; &lt;span style=&quot; color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif;&quot;&gt;Check out Program&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot; color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot; color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; line-height: 25px;&quot;&gt;#include&amp;lt;iostream.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot; color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; line-height: 25px;&quot;&gt;#include&amp;lt;conio.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot; color: #6aa84f; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; line-height: 25px;&quot;&gt;// Display Fibonacci Series&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot; color: #6aa84f; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; line-height: 25px;&quot;&gt;// In Fibonacci Series first two numbers in the Fibonacci series are 0 and 1, and each subsequent number is the sum of the previous two.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot; color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; line-height: 25px;&quot;&gt;int main()&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot; color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; line-height: 25px;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot; color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; line-height: 25px;&quot;&gt;int a=0,b=1, c,n;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 25px;&quot;&gt;cout &amp;lt;&amp;lt; &quot;Enter the value of n &quot;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 25px;&quot;&gt;&lt;span style=&quot;color: #333333;&quot;&gt;cin &amp;gt;&amp;gt; n; &lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;// n store the integer value that series will shown upto n terms&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; line-height: 25px;&quot;&gt;cout &amp;lt;&amp;lt; endl &amp;lt;&amp;lt; a &amp;lt;&amp;lt;&quot; &quot; &amp;lt;&amp;lt;b &amp;lt;&amp;lt; &quot; &quot; ;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; line-height: 25px;&quot;&gt;for(int i =0; i&amp;lt;(n-2); i++)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; line-height: 25px;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; line-height: 25px;&quot;&gt;c = a+ b;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; line-height: 25px;&quot;&gt;cout &amp;lt;&amp;lt; c &amp;lt;&amp;lt; &quot; &quot;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; line-height: 25px;&quot;&gt;a=b;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; line-height: 25px;&quot;&gt;b=c;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; line-height: 25px;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; line-height: 25px;&quot;&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;/* First we Print first Two Term of Series then using for loop we generate rest of series upto n term. Let Begin with loop first it begin from 0 till the n-2 term because we already print first two term of series, then inside loop we initialize c = a&amp;nbsp;+ b, c contain value sum of a&amp;nbsp;+ b which become the third term of series. In Fibonacci series sum of previous two term is the next term. After getting value of next term and store in variable c. Then swapping of variable take place, now we don&#39;t require first term for next term(i.e. 4th term) so we replace value of a with b and replace value of b with c. Now 1st contain 2nd and 2nd contain 3rd, so they can generate 4th and so on. This process going on until the nth term of series. It will Print output after every assigning value of c.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; line-height: 25px;&quot;&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; line-height: 25px;&quot;&gt;getch();&lt;/span&gt;&lt;span style=&quot; color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; line-height: 25px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot; color: #6aa84f; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; line-height: 25px;&quot;&gt;//http://cplspls.blogspot.com&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; line-height: 25px;&quot;&gt;return 0;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; line-height: 25px;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; line-height: 25px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;b style=&quot; color: #333333; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: large; line-height: 25px;&quot;&gt;OUTPUT:&lt;/b&gt;&lt;br /&gt;
&lt;b style=&quot; color: #333333; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: large; line-height: 25px;&quot;&gt;&lt;br /&gt;
&lt;/b&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/AVvXsEips_lZbLc8wWuD2K01tqbAhOjS4zNzsAs_DPh5c9Lk9I75ogr-OQRh_DVx5XJwiES-e7zGAGkf_i0VcE9qFgFFHHNi4s8_eqlJgn9-9IOx6Xz-pXYHmsfYabqyyaHI6oNHY_9HF1jI1-Dd/s1600/cpl01.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;130&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEips_lZbLc8wWuD2K01tqbAhOjS4zNzsAs_DPh5c9Lk9I75ogr-OQRh_DVx5XJwiES-e7zGAGkf_i0VcE9qFgFFHHNi4s8_eqlJgn9-9IOx6Xz-pXYHmsfYabqyyaHI6oNHY_9HF1jI1-Dd/s400/cpl01.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;b style=&quot; color: #333333; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: large; line-height: 25px;&quot;&gt;&lt;br /&gt;
&lt;/b&gt; &lt;br /&gt;
&lt;b style=&quot; color: #333333; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: large; line-height: 25px;&quot;&gt;Above Program Without Comments&lt;/b&gt;&lt;br /&gt;
&lt;span style=&quot; color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; line-height: 25px;&quot;&gt;#include&amp;lt;iostream.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot; color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; line-height: 25px;&quot;&gt;#include&amp;lt;conio.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot; color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; line-height: 25px;&quot;&gt;int main()&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot; color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; line-height: 25px;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot; color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; line-height: 25px;&quot;&gt;int a=0,b=1, c,n;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 25px;&quot;&gt;cout &amp;lt;&amp;lt; &quot;Enter the value of n &quot;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 25px;&quot;&gt;&lt;span style=&quot;color: #333333;&quot;&gt;cin &amp;gt;&amp;gt; n;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; line-height: 25px;&quot;&gt;cout &amp;lt;&amp;lt; endl &amp;lt;&amp;lt; a &amp;lt;&amp;lt;&quot; &quot; &amp;lt;&amp;lt;b &amp;lt;&amp;lt; &quot; &quot; ;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; line-height: 25px;&quot;&gt;for(int i =0; i&amp;lt;(n-2); i++)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; line-height: 25px;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; line-height: 25px;&quot;&gt;c = a+ b;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; line-height: 25px;&quot;&gt;cout &amp;lt;&amp;lt; c &amp;lt;&amp;lt; &quot; &quot;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; line-height: 25px;&quot;&gt;a=b;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; line-height: 25px;&quot;&gt;b=c;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; line-height: 25px;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; line-height: 25px;&quot;&gt;getch();&lt;/span&gt;&lt;span style=&quot; color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; line-height: 25px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot; color: #6aa84f; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; line-height: 25px;&quot;&gt;//http://cplspls.blogspot.com&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; line-height: 25px;&quot;&gt;return 0;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;helvetica neue light&amp;quot; , , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; line-height: 25px;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;b style=&quot; color: #333333; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: large; line-height: 25px;&quot;&gt;&lt;br /&gt;
&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;- Arshpreet Wadehra
http://twitter.com/wadehrarshpreet&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cplspls.blogspot.com/feeds/7298542694069550/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://cplspls.blogspot.com/2013/10/program-display-fibonacci-series.html#comment-form' title='10 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7607138261163784346/posts/default/7298542694069550'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7607138261163784346/posts/default/7298542694069550'/><link rel='alternate' type='text/html' href='http://cplspls.blogspot.com/2013/10/program-display-fibonacci-series.html' title='Program: Display Fibonacci Series IN C++'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEips_lZbLc8wWuD2K01tqbAhOjS4zNzsAs_DPh5c9Lk9I75ogr-OQRh_DVx5XJwiES-e7zGAGkf_i0VcE9qFgFFHHNi4s8_eqlJgn9-9IOx6Xz-pXYHmsfYabqyyaHI6oNHY_9HF1jI1-Dd/s72-c/cpl01.png" height="72" width="72"/><thr:total>10</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7607138261163784346.post-5125627381133142372</id><published>2013-10-04T04:10:00.001-07:00</published><updated>2013-10-04T04:13:52.940-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Programs"/><title type='text'>Program: Find Factorial of a Given Number</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span style=&quot;background-color: #fafafa; color: #333333; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: medium;&quot;&gt;&lt;b&gt;Program : FIND FACTORIAL OF A GIVEN NUMBER&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br style=&quot;background-color: #fafafa; color: #333333; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 19px;&quot; /&gt;
&lt;span style=&quot;background-color: #fafafa; color: #333333; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: medium;&quot;&gt;Program to find factorial of a number using For Loop&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #fafafa; color: #333333; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: medium;&quot;&gt;Check out Program&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #fafafa; color: #333333; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: medium;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: #fafafa; color: #333333; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: medium; line-height: 25px;&quot;&gt;#include&amp;lt;iostream.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #fafafa; color: #333333; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: medium; line-height: 25px;&quot;&gt;#include&amp;lt;conio.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #fafafa; color: #6aa84f; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: medium; line-height: 25px;&quot;&gt;// Find factorial of a Given Number&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #fafafa; color: #333333; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: medium; line-height: 25px;&quot;&gt;int main()&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #fafafa; color: #333333; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: medium; line-height: 25px;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #fafafa; color: #333333; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: medium; line-height: 25px;&quot;&gt;long double factorial = 1; &lt;/span&gt;&lt;span style=&quot;background-color: #fafafa; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: medium; line-height: 25px;&quot;&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;/* factorial has long double type which take 8 bytes in memory and it can store number within range of 1.7E -308 to 1.7E&amp;nbsp;+ 308 */&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #fafafa; color: #333333; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: medium; line-height: 25px;&quot;&gt;int n;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #fafafa; color: #333333; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: medium; line-height: 25px;&quot;&gt;cout &amp;lt;&amp;lt;&quot;Enter a Number : &quot;&amp;lt;&amp;lt;endl; // &lt;/span&gt;&lt;span style=&quot;background-color: #fafafa; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: medium; line-height: 25px;&quot;&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;endl for new line&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #fafafa; color: #333333; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: medium; line-height: 25px;&quot;&gt;cin &amp;gt;&amp;gt; n; // &lt;/span&gt;&lt;span style=&quot;background-color: #fafafa; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: medium; line-height: 25px;&quot;&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;Take Integer value from user and store in variable n&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #fafafa; color: #333333; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: medium; line-height: 25px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: #fafafa; color: #333333; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: medium; line-height: 25px;&quot;&gt;for(int i =n; i&amp;gt;0; i--)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #fafafa; color: #333333; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: medium; line-height: 25px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;factorial *= i;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #fafafa; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: medium; line-height: 25px;&quot;&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;/* You Know Factorial is product of all positive number integers less than or equal to n. In above loop we initialize i equal to value of n that is taken from user, then set condition that i &amp;gt; 0 because we do multiplication here if i = 0 then it will give result 0. Then in loop statement is factorial * = i , it means that factorial = factorial * i , Now we already assign factorial value as 1, if we don&#39;t assign value 1 it will give error or junk value, because we are doing multiply if there is no number to multiply with it give junk value. In this we use decrement of value of i from n to 1, so it will multiply number like this n * (n-1) * (n-2) * ... * 2 * 1 . In this loop i didn&#39;t put braces because any loop or condition if you didn&#39;t put braces then it will automatic consider next line or till the termination(;) it will consider that part inside loop. So next line to loop inside the loop after that loop scope is finished.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #fafafa; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: medium; line-height: 25px;&quot;&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #fafafa; color: #333333; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: medium; line-height: 25px;&quot;&gt;cout &amp;lt;&amp;lt; n &amp;lt;&amp;lt; &quot;! = &quot; &amp;lt;&amp;lt; factorial &amp;lt;&amp;lt;endl;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #fafafa; color: #333333; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: medium; line-height: 25px;&quot;&gt;getch();&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: #fafafa; color: #6aa84f; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: medium; line-height: 25px;&quot;&gt;//http://cplspls.blogspot.com&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #fafafa; color: #333333; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: medium; line-height: 25px;&quot;&gt;return 0;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #fafafa; color: #333333; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: medium; line-height: 25px;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #fafafa; color: #333333; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: medium; line-height: 25px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;b style=&quot;background-color: #fafafa; color: #333333; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: large; line-height: 25px;&quot;&gt;OUTPUT:&lt;/b&gt;&lt;br /&gt;
&lt;b style=&quot;background-color: #fafafa; color: #333333; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: large; line-height: 25px;&quot;&gt;&lt;br /&gt;&lt;/b&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/AVvXsEhYtCApyCR1xT0xdyBvn-9I9fWJalYHrdF8NNKQHKJbFjxSa1t-GoFkwXfpZpSj0xIrpI5aJHFWrgOSVrcXfIQxISbbnf476jTqeZTurBBjMKZsJxD24LvOo1KJydle4ODYFDtJOSHgt8YZ/s1600/cpl00.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYtCApyCR1xT0xdyBvn-9I9fWJalYHrdF8NNKQHKJbFjxSa1t-GoFkwXfpZpSj0xIrpI5aJHFWrgOSVrcXfIQxISbbnf476jTqeZTurBBjMKZsJxD24LvOo1KJydle4ODYFDtJOSHgt8YZ/s1600/cpl00.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;b style=&quot;background-color: #fafafa; color: #333333; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: large; line-height: 25px;&quot;&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b style=&quot;background-color: #fafafa; color: #333333; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: large; line-height: 25px;&quot;&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b style=&quot;background-color: #fafafa; color: #333333; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: large; line-height: 25px;&quot;&gt;&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b style=&quot;background-color: #fafafa; color: #333333; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: large; line-height: 25px;&quot;&gt;Above Program Without Comments&lt;/b&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #fafafa; color: #333333; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: medium; line-height: 25px;&quot;&gt;#include&amp;lt;iostream.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #fafafa; color: #333333; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: medium; line-height: 25px;&quot;&gt;#include&amp;lt;conio.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #fafafa; color: #333333; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: medium; line-height: 25px;&quot;&gt;int main()&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #fafafa; color: #333333; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: medium; line-height: 25px;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #fafafa; color: #333333; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: medium; line-height: 25px;&quot;&gt;long double factorial = 1;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #fafafa; color: #333333; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: medium; line-height: 25px;&quot;&gt;int n;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #fafafa; color: #333333; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: medium; line-height: 25px;&quot;&gt;cout &amp;lt;&amp;lt;&quot;Enter a Number : &quot;&amp;lt;&amp;lt;endl;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #fafafa; color: #333333; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: medium; line-height: 25px;&quot;&gt;cin &amp;gt;&amp;gt; n;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #fafafa; color: #333333; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: medium; line-height: 25px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;background-color: #fafafa; color: #333333; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: medium; line-height: 25px;&quot;&gt;for(int i =n; i&amp;gt;0; i--)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #fafafa; color: #333333; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: medium; line-height: 25px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;factorial *= i;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;background-color: #fafafa; color: #333333; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: medium; line-height: 25px;&quot;&gt;cout &amp;lt;&amp;lt; n &amp;lt;&amp;lt; &quot;! = &quot; &amp;lt;&amp;lt; factorial &amp;lt;&amp;lt;endl;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #fafafa; color: #333333; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: medium; line-height: 25px;&quot;&gt;getch();&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #fafafa; color: #333333; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: medium; line-height: 25px;&quot;&gt;return 0;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #fafafa; color: #333333; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: medium; line-height: 25px;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;b style=&quot;background-color: #fafafa; color: #333333; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: large; line-height: 25px;&quot;&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;- Arshpreet Wadehra
http://twitter.com/wadehrarshpreet&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cplspls.blogspot.com/feeds/5125627381133142372/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://cplspls.blogspot.com/2013/10/program-find-factorial-of-given-number.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7607138261163784346/posts/default/5125627381133142372'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7607138261163784346/posts/default/5125627381133142372'/><link rel='alternate' type='text/html' href='http://cplspls.blogspot.com/2013/10/program-find-factorial-of-given-number.html' title='Program: Find Factorial of a Given Number'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYtCApyCR1xT0xdyBvn-9I9fWJalYHrdF8NNKQHKJbFjxSa1t-GoFkwXfpZpSj0xIrpI5aJHFWrgOSVrcXfIQxISbbnf476jTqeZTurBBjMKZsJxD24LvOo1KJydle4ODYFDtJOSHgt8YZ/s72-c/cpl00.png" height="72" width="72"/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7607138261163784346.post-1397314347692298093</id><published>2012-01-28T22:07:00.000-08:00</published><updated>2015-08-28T03:34:24.299-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Programs"/><title type='text'>Program : Equilateral Triangle empty from inside</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Program : Equilateral Triangle empty from inside&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Program to create a triangle like only triangle outline&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Check out Program&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;#include&amp;lt;iostream.h&amp;gt;&lt;br /&gt;#include&amp;lt;conio.h&amp;gt;&lt;br /&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;// Create an Equilateral Triangle empty from inside&lt;/span&gt;&lt;br /&gt;int main()&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; int i=0,sp; &lt;span style=&quot;color: #6aa84f;&quot;&gt;// int define i and sp &lt;/span&gt;&lt;br /&gt;&amp;nbsp; for(i=0; i&amp;lt;=10; i++) &lt;span style=&quot;color: #6aa84f;&quot;&gt;// first loop that work for 11 times&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for(int sp=0; sp&amp;lt;=10-i; sp++) &lt;span style=&quot;color: #6aa84f;&quot;&gt;// loop for space like first time 5 &lt;/span&gt;then 4 then 3 and so on&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cout &amp;lt;&amp;lt; &quot; &quot;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for(int j=0; j&amp;lt;1; j++) &lt;span style=&quot;color: #6aa84f;&quot;&gt;// loop to print xx that work only one &lt;/span&gt;time&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cout &amp;lt;&amp;lt;&quot;x&quot;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for(int m=0; m&amp;lt;=2*i; m++) &lt;span style=&quot;color: #6aa84f;&quot;&gt;// inside this one loop for give &lt;/span&gt;space b/w two x&lt;br /&gt;{&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cout&amp;lt;&amp;lt;&quot; &quot;;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cout &amp;lt;&amp;lt;&quot;x&quot;; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cout &amp;lt;&amp;lt;endl; &lt;span style=&quot;color: #6aa84f;&quot;&gt;//next line&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for(int s=0; s&amp;lt;=i; s++)&amp;nbsp; &lt;span style=&quot;color: #6aa84f;&quot;&gt;//print last line with xx&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cout &amp;lt;&amp;lt; &quot;xx&quot;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cout &amp;lt;&amp;lt;endl;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; getch(); &lt;span style=&quot;color: #6aa84f;&quot;&gt;//http://cplspls.blogspot.com&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return 0;&lt;br /&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt; &lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt; &lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;OUTPUT: &lt;/b&gt;&lt;/span&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/AVvXsEjuJ8orB8B3sj34cQhFpeF7b3k4hNjalYMaHSU6asWzgm9hRpzb8bZ4WZETPyWOvRVMmsTcsZbghip4RWrJpqYqxncqxyp3v6ZXmeetouK0xz8VrW_qcMcNQXoWl3naxU5gWwPd6I3U5odS/s1600/out23.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuJ8orB8B3sj34cQhFpeF7b3k4hNjalYMaHSU6asWzgm9hRpzb8bZ4WZETPyWOvRVMmsTcsZbghip4RWrJpqYqxncqxyp3v6ZXmeetouK0xz8VrW_qcMcNQXoWl3naxU5gWwPd6I3U5odS/s1600/out23.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;- Arshpreet Wadehra
http://twitter.com/wadehrarshpreet&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cplspls.blogspot.com/feeds/1397314347692298093/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://cplspls.blogspot.com/2012/01/program-equilateral-triangle-empty-from.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7607138261163784346/posts/default/1397314347692298093'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7607138261163784346/posts/default/1397314347692298093'/><link rel='alternate' type='text/html' href='http://cplspls.blogspot.com/2012/01/program-equilateral-triangle-empty-from.html' title='Program : Equilateral Triangle empty from inside'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuJ8orB8B3sj34cQhFpeF7b3k4hNjalYMaHSU6asWzgm9hRpzb8bZ4WZETPyWOvRVMmsTcsZbghip4RWrJpqYqxncqxyp3v6ZXmeetouK0xz8VrW_qcMcNQXoWl3naxU5gWwPd6I3U5odS/s72-c/out23.png" height="72" width="72"/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7607138261163784346.post-6695122681847226714</id><published>2012-01-11T04:06:00.000-08:00</published><updated>2015-08-28T03:34:41.808-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Built in Functions"/><category scheme="http://www.blogger.com/atom/ns#" term="Introduction"/><title type='text'>Using Switch &amp; break Statement</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Using Switch &amp;amp; Break Statement&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Switch statement is used instead of if statement using if statement multiple time can replace with switch and this make program short.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Break statement is used break that code proceed next like for loop i set to run 5 time and i write break it only run 1 time it skip braces part and continue to rest of code. Its used in loops and switch...&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;syntax of switch:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt; switch(variable)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;{case 1 : &lt;/span&gt;&lt;span style=&quot;font-size: large;&quot;&gt;statement&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;break; &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;case 2 : &lt;/span&gt;&lt;span style=&quot;font-size: large;&quot;&gt;statement&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;break;&lt;/span&gt;&lt;span style=&quot;font-size: large;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;case 3 :&lt;/span&gt;&lt;span style=&quot;font-size: large;&quot;&gt; statement&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;break;&lt;/span&gt;&lt;span style=&quot;font-size: large;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;...&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;...&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;default : statement&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;break;&lt;/span&gt;&lt;span style=&quot;font-size: large;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Check the example:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;#include&amp;lt;iostream.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;#include&amp;lt;conio.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;int main()&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;{char a;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;color: #6aa84f;&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;//check the user input is vowel or not&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;cout &amp;lt;&amp;lt; &quot;Enter any character \n&quot;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;cin &amp;gt;&amp;gt;a;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;switch(a) &lt;span style=&quot;color: #6aa84f;&quot;&gt;//no semi colon&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;case &#39;a&#39;:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;case &#39;e&#39;:&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;case &#39;i&#39;:&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;case &#39;o&#39;:&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;case &#39;u&#39;:&lt;br /&gt;
&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;case &#39;A&#39;:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;case &#39;E&#39;:&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;case &#39;I&#39;:&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;case &#39;O&#39;:&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;case &#39;U&#39;: cout&amp;lt;&amp;lt;&quot;Your input is Vowel\n&quot;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;break;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;default : cout &amp;lt;&amp;lt; &quot;Your input is not vowel\n&quot;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;break; &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;color: #6aa84f;&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;/*&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #6aa84f;&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;above i take input from user and under switch braces i write that variable here choice is made and it switch to according to that Case&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #6aa84f;&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;like here if i enter a character then it goto switch(a) then it redirect to selected case like case &#39;a&#39; then it print&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #6aa84f;&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&#39;Your input is Vowel&#39;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #6aa84f;&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;if you enter anything z then it redirect to default that display &lt;/span&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #6aa84f;&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&#39;Your input is not vowel&#39;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #6aa84f;&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;and break statement is necessary to differentiate cases that if you didn&#39;t write break then it execute all other cases after that like if i enter a then it also print your input is not vowel if i didn&#39;t set break&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #6aa84f;&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;thats why i write only one time&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #6aa84f;&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&#39;Your input is Vowel&#39;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #6aa84f;&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;and no break between them and in end i set break!!! &lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #6aa84f;&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;getch();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;return 0;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;OUTPUT&lt;/span&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/AVvXsEgcdUO8OION9bTKY2tYlWXHZHgvpldk3Hw1-C-WNyxmV_A7KqvRKL4ggVuAgqphXm4-YXkIaXYRUMcz1PjlSUh8YnqVmC6N__0U0b95sbeX6MzuqBm9eYEs42FyiZ0pkfzDLBqYzrPB-Ipp/s1600/out22.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgcdUO8OION9bTKY2tYlWXHZHgvpldk3Hw1-C-WNyxmV_A7KqvRKL4ggVuAgqphXm4-YXkIaXYRUMcz1PjlSUh8YnqVmC6N__0U0b95sbeX6MzuqBm9eYEs42FyiZ0pkfzDLBqYzrPB-Ipp/s1600/out22.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;- Arshpreet Wadehra
http://twitter.com/wadehrarshpreet&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cplspls.blogspot.com/feeds/6695122681847226714/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://cplspls.blogspot.com/2012/01/using-switch-break-statement.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7607138261163784346/posts/default/6695122681847226714'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7607138261163784346/posts/default/6695122681847226714'/><link rel='alternate' type='text/html' href='http://cplspls.blogspot.com/2012/01/using-switch-break-statement.html' title='Using Switch &amp; break Statement'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgcdUO8OION9bTKY2tYlWXHZHgvpldk3Hw1-C-WNyxmV_A7KqvRKL4ggVuAgqphXm4-YXkIaXYRUMcz1PjlSUh8YnqVmC6N__0U0b95sbeX6MzuqBm9eYEs42FyiZ0pkfzDLBqYzrPB-Ipp/s72-c/out22.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7607138261163784346.post-5539706720621709756</id><published>2012-01-07T23:47:00.000-08:00</published><updated>2015-08-28T03:35:13.985-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Programs"/><title type='text'>Program: To check given character is Alphabet, Digit or any Other</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;&amp;nbsp;Program: To check given character is Alphabet, Digit or any Other&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;#include&amp;lt;iostream.h&amp;gt;&lt;br /&gt;#include&amp;lt;conio.h&amp;gt;&lt;br /&gt;//check given character is alphabets, digit or any other character&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;int main()&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;char a;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;cout &amp;lt;&amp;lt;&quot;Enter a character : \n&quot;;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;cin &amp;gt;&amp;gt; a;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;if(((a &amp;gt;= &#39;A&#39;) &amp;amp;&amp;amp; (a&amp;lt;=&#39;Z&#39;)) || ((a &amp;gt;=&#39;a&#39;) &amp;amp;&amp;amp; (a &amp;lt;= &#39;z&#39;)))&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;cout &amp;lt;&amp;lt; &quot;You entered an Alphabet\n&quot;;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;else if(a &amp;gt;= &#39;0&#39; &amp;amp;&amp;amp; a &amp;lt;=&#39;9&#39;)&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;cout &amp;lt;&amp;lt; &quot;You entered a digit\n&quot;;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;else &lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;cout &amp;lt;&amp;lt; &quot;You entered non alpha numeric character\n&quot;;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;/* i define char a that contain only one character and then i take input&lt;/span&gt;&lt;br style=&quot;color: #6aa84f;&quot; /&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;from user. and then i set condition to check what type of data user enter&lt;/span&gt;&lt;br style=&quot;color: #6aa84f;&quot; /&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;first condition that i set a &amp;gt;= &#39;A&#39; &amp;amp;&amp;amp; a&amp;lt;=&#39;Z&#39; and in these i write two condition]&lt;/span&gt;&lt;br style=&quot;color: #6aa84f;&quot; /&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;joining with &amp;amp;&amp;amp; now understand the function of &amp;amp;&amp;amp; this is used to check that both the condition is&lt;/span&gt;&lt;br style=&quot;color: #6aa84f;&quot; /&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;true or false like here i set a&amp;gt;= &#39;A&#39; &amp;amp;&amp;amp; a&amp;lt;=&#39;Z&#39; this condition run when both is true&lt;/span&gt;&lt;br style=&quot;color: #6aa84f;&quot; /&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;this condition mean that value is between A &amp;amp; Z and now see full condition&lt;/span&gt;&lt;br style=&quot;color: #6aa84f;&quot; /&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;that condition i for uppercase now check for lower case we separate condition&lt;/span&gt;&lt;br style=&quot;color: #6aa84f;&quot; /&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;with OR sign &#39;||&#39; this mean condition must true either one of the side must true&lt;/span&gt;&lt;br style=&quot;color: #6aa84f;&quot; /&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;like here (((a &amp;gt;= &#39;A&#39;) &amp;amp;&amp;amp; (a&amp;lt;=&#39;Z&#39;)) || ((a &amp;gt;=&#39;a&#39;) &amp;amp;&amp;amp; (a &amp;lt;= &#39;z&#39;)))&lt;/span&gt;&lt;br style=&quot;color: #6aa84f;&quot; /&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;first uppercase check if it false then it check lower case either one of these&lt;/span&gt;&lt;br style=&quot;color: #6aa84f;&quot; /&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;true then only it execute then it print you enter alphabet&lt;/span&gt;&lt;br style=&quot;color: #6aa84f;&quot; /&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;br style=&quot;color: #6aa84f;&quot; /&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;Now second condition you can see to check number (a &amp;gt;= &#39;0&#39; &amp;amp;&amp;amp; a &amp;lt;=&#39;9&#39;)&lt;/span&gt;&lt;br style=&quot;color: #6aa84f;&quot; /&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;i use else if condition u can also use if condition under else &lt;/span&gt;&lt;br style=&quot;color: #6aa84f;&quot; /&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;like else&lt;/span&gt;&lt;br style=&quot;color: #6aa84f;&quot; /&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;{&lt;/span&gt;&lt;br style=&quot;color: #6aa84f;&quot; /&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;if((a &amp;gt;= &#39;0&#39; &amp;amp;&amp;amp; a &amp;lt;=&#39;9&#39;)&lt;/span&gt;&lt;br style=&quot;color: #6aa84f;&quot; /&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;cout&amp;lt;&amp;lt;&quot;You enter Number&quot;;&lt;/span&gt;&lt;br style=&quot;color: #6aa84f;&quot; /&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/span&gt;&lt;br style=&quot;color: #6aa84f;&quot; /&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;br style=&quot;color: #6aa84f;&quot; /&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;like this you can also give its same the above condition check the number&lt;/span&gt;&lt;br style=&quot;color: #6aa84f;&quot; /&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;between 0 to 9&lt;/span&gt;&lt;br style=&quot;color: #6aa84f;&quot; /&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;br style=&quot;color: #6aa84f;&quot; /&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;and third is else part other than above number or alphabet it execute &lt;/span&gt;&lt;br style=&quot;color: #6aa84f;&quot; /&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;that part&lt;/span&gt;&lt;br style=&quot;color: #6aa84f;&quot; /&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;*/&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;getch();&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;return 0;&lt;br /&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;OUTPUT&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgvkyIqTqcijVZnUs-arow1TzphYJi6-WSEL_6pAd6CElwUFuK4UJ4GxO3dFCM9ibiqMQX7SpwPR0CpwGc4qtwKJnFZb4Ti4VRvsZU8gc999133Yl6YELIxcXunC9GmuusAJCb3n6bwFzTb/s1600/out21.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgvkyIqTqcijVZnUs-arow1TzphYJi6-WSEL_6pAd6CElwUFuK4UJ4GxO3dFCM9ibiqMQX7SpwPR0CpwGc4qtwKJnFZb4Ti4VRvsZU8gc999133Yl6YELIxcXunC9GmuusAJCb3n6bwFzTb/s1600/out21.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;- Arshpreet Wadehra
http://twitter.com/wadehrarshpreet&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cplspls.blogspot.com/feeds/5539706720621709756/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://cplspls.blogspot.com/2012/01/program-to-check-given-character-is.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7607138261163784346/posts/default/5539706720621709756'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7607138261163784346/posts/default/5539706720621709756'/><link rel='alternate' type='text/html' href='http://cplspls.blogspot.com/2012/01/program-to-check-given-character-is.html' title='Program: To check given character is Alphabet, Digit or any Other'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgvkyIqTqcijVZnUs-arow1TzphYJi6-WSEL_6pAd6CElwUFuK4UJ4GxO3dFCM9ibiqMQX7SpwPR0CpwGc4qtwKJnFZb4Ti4VRvsZU8gc999133Yl6YELIxcXunC9GmuusAJCb3n6bwFzTb/s72-c/out21.png" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7607138261163784346.post-3534774341645185633</id><published>2012-01-07T07:41:00.000-08:00</published><updated>2015-08-28T03:35:34.223-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Programs"/><title type='text'>Program : To Accept 5 Integer and Print Larger one</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&amp;nbsp;Program : To Accept 5 Integer and Print Larger one using if statement&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;In this program i use if statement to check the largest no.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;check the program:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;#include&amp;lt;iostream.h&amp;gt;&lt;br /&gt;#include&amp;lt;conio.h&amp;gt;&lt;br /&gt;//Accept 5 Integer and Print Larger one&lt;br /&gt;int main()&lt;br /&gt;{&lt;br /&gt;int a,b,c,d,e,f;&lt;br /&gt;cout &amp;lt;&amp;lt; &quot;Enter Five Number\n&quot;;&lt;br /&gt;cin &amp;gt;&amp;gt; a &amp;gt;&amp;gt; b &amp;gt;&amp;gt; c &amp;gt;&amp;gt; d &amp;gt;&amp;gt;e; &lt;span style=&quot;color: #6aa84f;&quot;&gt;//it take 5 no one after one&lt;/span&gt;&lt;br style=&quot;color: #6aa84f;&quot; /&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;//let f is maximum no. &amp;amp; set that no. to be a variable&lt;/span&gt;&lt;br /&gt;f =a;&lt;br /&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;//we assume a is max and then we set the condition with if &lt;/span&gt;&lt;br style=&quot;color: #6aa84f;&quot; /&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;// statement and it will swap f value to largest one let chek it out&lt;/span&gt;&lt;br /&gt;if(b&amp;gt;f)&lt;br /&gt;f =b;&lt;br /&gt;if(c&amp;gt;f)&lt;br /&gt;f=c;&lt;br /&gt;if(d&amp;gt;f)&lt;br /&gt;f=d;&lt;br /&gt;if(e&amp;gt;f)&lt;br /&gt;f=e;&lt;br /&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;/*&lt;/span&gt;&lt;br style=&quot;color: #6aa84f;&quot; /&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;In this&amp;nbsp; i set 4 condition and u see every condition give i didnt give any braces&lt;/span&gt;&lt;br style=&quot;color: #6aa84f;&quot; /&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;because when we write without braces then it autoatc consider its scope&lt;/span&gt;&lt;br style=&quot;color: #6aa84f;&quot; /&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;that next line to that condition only&lt;/span&gt;&lt;br style=&quot;color: #6aa84f;&quot; /&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;like in every four condition aboce the scope of &lt;/span&gt;&lt;br style=&quot;color: #6aa84f;&quot; /&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;assigning value is till there only one line&lt;/span&gt;&lt;br style=&quot;color: #6aa84f;&quot; /&gt;&lt;br style=&quot;color: #6aa84f;&quot; /&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;and above condition replace no according to condition true&lt;/span&gt;&lt;br style=&quot;color: #6aa84f;&quot; /&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;that no greater than f&lt;/span&gt;&lt;br style=&quot;color: #6aa84f;&quot; /&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;Its simple using if statement&lt;/span&gt;&lt;br style=&quot;color: #6aa84f;&quot; /&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;*/&lt;/span&gt;&lt;br /&gt;cout &amp;lt;&amp;lt; &quot;Largest No is &quot; &amp;lt;&amp;lt; f;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; getch();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return 0;&lt;br /&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;OUTPUT&lt;/span&gt;&lt;/b&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/AVvXsEjTvZY1Q7ZPmwgRO4E33URbxzxx-DxjneWj7URzyOKY_ym0tloWVn8qoG4yvxgv2YWhg6QfcHNpKPgFYI6Su7lc8oNsEsx6XaBdjqalHnR1kSUfV1aBpnJj_qkQ97H-PD0KqXObpn449G9t/s1600/out20.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjTvZY1Q7ZPmwgRO4E33URbxzxx-DxjneWj7URzyOKY_ym0tloWVn8qoG4yvxgv2YWhg6QfcHNpKPgFYI6Su7lc8oNsEsx6XaBdjqalHnR1kSUfV1aBpnJj_qkQ97H-PD0KqXObpn449G9t/s1600/out20.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;- Arshpreet Wadehra
http://twitter.com/wadehrarshpreet&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cplspls.blogspot.com/feeds/3534774341645185633/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://cplspls.blogspot.com/2012/01/program-to-accept-5-integer-and-print.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7607138261163784346/posts/default/3534774341645185633'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7607138261163784346/posts/default/3534774341645185633'/><link rel='alternate' type='text/html' href='http://cplspls.blogspot.com/2012/01/program-to-accept-5-integer-and-print.html' title='Program : To Accept 5 Integer and Print Larger one'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjTvZY1Q7ZPmwgRO4E33URbxzxx-DxjneWj7URzyOKY_ym0tloWVn8qoG4yvxgv2YWhg6QfcHNpKPgFYI6Su7lc8oNsEsx6XaBdjqalHnR1kSUfV1aBpnJj_qkQ97H-PD0KqXObpn449G9t/s72-c/out20.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7607138261163784346.post-8213393149184765033</id><published>2012-01-07T07:06:00.000-08:00</published><updated>2015-08-28T03:35:57.175-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Programs"/><title type='text'>Program : Create Equilateral triangle</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&amp;nbsp;&lt;b&gt;Program : Create Equilateral triangle&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;To make an Equilateral triangle&lt;b&gt; &lt;/b&gt;we need total three loop&lt;b&gt; &lt;/b&gt;two loop inside one loop. It will print Equilateral Triangle using word xx&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Check Out Program for Better Understand.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;#include&amp;lt;iostream.h&amp;gt;&lt;br /&gt;#include&amp;lt;conio.h&amp;gt;&lt;br /&gt;// Create an Equilateral Triangle&lt;br /&gt;int main()&lt;br /&gt;{&lt;br /&gt;&amp;nbsp; for(int i=1; i&amp;lt;=8; i++)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for(int sp=1; sp&amp;lt;=8-i; sp++)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cout &amp;lt;&amp;lt; &quot; &quot;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for(int j=1; j&amp;lt;=i; j++)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cout &amp;lt;&amp;lt;&quot;xx&quot;; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cout &amp;lt;&amp;lt;endl; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;/* Loop set to int i = 1 and less than or equal to 8 this means this&lt;/span&gt;&lt;br style=&quot;color: #6aa84f;&quot; /&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;loop run 8 times under every time two more loop runs one that loop&lt;/span&gt;&lt;br style=&quot;color: #6aa84f;&quot; /&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;give space like i wanna make xx equilateral triable like that&lt;/span&gt;&lt;br style=&quot;color: #6aa84f;&quot; /&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;____xx____&lt;/span&gt;&lt;br style=&quot;color: #6aa84f;&quot; /&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;___xxxx___&lt;/span&gt;&lt;br style=&quot;color: #6aa84f;&quot; /&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;__xxxxxx__&lt;/span&gt;&lt;br style=&quot;color: #6aa84f;&quot; /&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;_xxxxxxxx_&lt;/span&gt;&lt;br style=&quot;color: #6aa84f;&quot; /&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;like this _ is space, we need to give this space i use 2nd loop&lt;/span&gt;&lt;br style=&quot;color: #6aa84f;&quot; /&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;and this loop help to give spaces that here&lt;/span&gt;&lt;br style=&quot;color: #6aa84f;&quot; /&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;i give first 7 space than next line 6 next 5 and so on &lt;/span&gt;&lt;br style=&quot;color: #6aa84f;&quot; /&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;i set sp value to 1 and sp &amp;lt;=8-i initially i =1 and this imply sp value&lt;/span&gt;&lt;br style=&quot;color: #6aa84f;&quot; /&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;is less than or equal to 7 at begin and this give 7 spaces and then&lt;/span&gt;&lt;br style=&quot;color: #6aa84f;&quot; /&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;Now 7 spaces is given &lt;/span&gt;&lt;br style=&quot;color: #6aa84f;&quot; /&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;then it proceed to next loop that is to print the xx&lt;/span&gt;&lt;br style=&quot;color: #6aa84f;&quot; /&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;initally value of j =1 and its less than or equal to i and &lt;/span&gt;&lt;br style=&quot;color: #6aa84f;&quot; /&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;initially i =1 and the condition is true then its run and print&lt;/span&gt;&lt;br style=&quot;color: #6aa84f;&quot; /&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;xx one time&lt;/span&gt;&lt;br style=&quot;color: #6aa84f;&quot; /&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;and then it give new line &lt;/span&gt;&lt;br style=&quot;color: #6aa84f;&quot; /&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;and then i increment is done and same procedure done again &lt;/span&gt;&lt;br style=&quot;color: #6aa84f;&quot; /&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;now in space loop it give 6 spaces &lt;/span&gt;&lt;br style=&quot;color: #6aa84f;&quot; /&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;and then print xx two times&lt;/span&gt;&lt;br style=&quot;color: #6aa84f;&quot; /&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;and then next line&lt;/span&gt;&lt;br style=&quot;color: #6aa84f;&quot; /&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;and this procedure go on...&lt;/span&gt;&lt;br style=&quot;color: #6aa84f;&quot; /&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;*/&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; getch();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return 0;&lt;br /&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;OUTPUT&lt;/b&gt;&lt;/span&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/AVvXsEjjrvRlIHvOXEOv8FO4K3z42xYk1LZheFPe97Bw75hhxf6prANS0gkJVjCUEHx08TxuQnLwW876z883XQdxoEfKXcTzpqge18uVrkl3OSwN9Vakp4AYerSSHFOh1V-RWJtRkwZYAjA9hTXs/s1600/out19.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjrvRlIHvOXEOv8FO4K3z42xYk1LZheFPe97Bw75hhxf6prANS0gkJVjCUEHx08TxuQnLwW876z883XQdxoEfKXcTzpqge18uVrkl3OSwN9Vakp4AYerSSHFOh1V-RWJtRkwZYAjA9hTXs/s1600/out19.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;- Arshpreet Wadehra
http://twitter.com/wadehrarshpreet&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cplspls.blogspot.com/feeds/8213393149184765033/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://cplspls.blogspot.com/2012/01/program-create-equilateral-triangle.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7607138261163784346/posts/default/8213393149184765033'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7607138261163784346/posts/default/8213393149184765033'/><link rel='alternate' type='text/html' href='http://cplspls.blogspot.com/2012/01/program-create-equilateral-triangle.html' title='Program : Create Equilateral triangle'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjrvRlIHvOXEOv8FO4K3z42xYk1LZheFPe97Bw75hhxf6prANS0gkJVjCUEHx08TxuQnLwW876z883XQdxoEfKXcTzpqge18uVrkl3OSwN9Vakp4AYerSSHFOh1V-RWJtRkwZYAjA9hTXs/s72-c/out19.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7607138261163784346.post-1559580932813702635</id><published>2012-01-05T08:11:00.000-08:00</published><updated>2015-08-28T03:36:11.268-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Programs"/><title type='text'>Program :Make Alphabet Triangle</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Program :Make Alphabet Triangle&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;In This Program I use Nested Loop To Make a Alphabet Triangle check out Program. &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;#include&amp;lt;iostream.h&amp;gt;&lt;br /&gt;#include&amp;lt;conio.h&amp;gt;&lt;br /&gt;int main()&lt;br /&gt;{&lt;br /&gt;for(int i=65; i&amp;lt;75; i++)&amp;nbsp; &lt;span style=&quot;color: #6aa84f;&quot;&gt;//i=65 that in ASCII 65 = A&lt;/span&gt;&lt;br /&gt;{ &lt;span style=&quot;color: #6aa84f;&quot;&gt;// and 75 is K but it will less than 75 so it print till J&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for(int j=0; j&amp;lt;10-i+65; j++) &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; { &lt;span style=&quot;color: #6aa84f;&quot;&gt;/* here i set j=0 and j &amp;lt; less than (10 - i) that i set to it decrease one by one so in this I add 65 in i so keep i zero at start and increase one by one */&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cout &amp;lt;&amp;lt; (char)i;&lt;span style=&quot;color: #6aa84f;&quot;&gt; // to convert int to char so i write (char) before write variable&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cout &amp;lt;&amp;lt; endl; &lt;span style=&quot;color: #6aa84f;&quot;&gt;// new line use every time it print one alphabets &lt;/span&gt;&lt;br /&gt;}&lt;br /&gt;getch();&lt;br /&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;OUTPUT&lt;/span&gt;&lt;/b&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/AVvXsEjfCEctjHGsPitlEEq3sSLNLnWglSex-fT4am6SnK5Qj_giXDXhkiVObRW70cvO_fcQ00rZP6hc-j58ETcokp_IF5hcoRIJuEMux79Gqlf7Mfr4YxQ94LXdIqlxldxCd9ji5ayWUcEIGXyq/s1600/out18.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfCEctjHGsPitlEEq3sSLNLnWglSex-fT4am6SnK5Qj_giXDXhkiVObRW70cvO_fcQ00rZP6hc-j58ETcokp_IF5hcoRIJuEMux79Gqlf7Mfr4YxQ94LXdIqlxldxCd9ji5ayWUcEIGXyq/s1600/out18.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;- Arshpreet Wadehra
http://twitter.com/wadehrarshpreet&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cplspls.blogspot.com/feeds/1559580932813702635/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://cplspls.blogspot.com/2012/01/program-make-alphabet-triangle.html#comment-form' title='24 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7607138261163784346/posts/default/1559580932813702635'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7607138261163784346/posts/default/1559580932813702635'/><link rel='alternate' type='text/html' href='http://cplspls.blogspot.com/2012/01/program-make-alphabet-triangle.html' title='Program :Make Alphabet Triangle'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfCEctjHGsPitlEEq3sSLNLnWglSex-fT4am6SnK5Qj_giXDXhkiVObRW70cvO_fcQ00rZP6hc-j58ETcokp_IF5hcoRIJuEMux79Gqlf7Mfr4YxQ94LXdIqlxldxCd9ji5ayWUcEIGXyq/s72-c/out18.png" height="72" width="72"/><thr:total>24</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7607138261163784346.post-6055667203829409251</id><published>2012-01-05T07:53:00.000-08:00</published><updated>2015-08-28T03:44:58.780-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Introduction"/><category scheme="http://www.blogger.com/atom/ns#" term="Programs"/><title type='text'>Using Nested Loop</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&amp;nbsp;Using Nested Loop&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Nested Loop is using loop inside a loop like for loop is under for loop for example:&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;for(int i=0;i&amp;lt;10;i++)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;{for(int j=0; j&amp;lt;4; j++)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;{cout&amp;lt;&amp;lt;i;} &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Above code is use like that first i value is 0 then condition true and then second loop is run it run for 4 times then increment is done and i value is 1 now and condition is true so it run again means the i loop run for 10 times and in every time i loop run 4 time second loop runs so total 40 times loop Run.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt; Check out Example of Number Triangle&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;#include&amp;lt;iostream.h&amp;gt;&lt;br /&gt;#include&amp;lt;conio.h&amp;gt;&lt;br /&gt;//Using Nested Loop&lt;br /&gt;int main()&lt;br /&gt;{&lt;br /&gt;for(int i=1; i&amp;lt;10; i++)&amp;nbsp; &lt;span style=&quot;color: #6aa84f;&quot;&gt;// i set to 1 and less than 10&lt;/span&gt;&lt;br /&gt;{ &lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;for(int j=0; j&amp;lt;i; j++) &lt;span style=&quot;color: #6aa84f;&quot;&gt;// j set to 0 and j less than i&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;cout &amp;lt;&amp;lt; i;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;cout &amp;lt;&amp;lt; endl;&lt;br /&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;/* above code first i=1 and j=0 and it print 1 only one time because condition true that j &amp;lt; i (i=1) and new line&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;then increment is done and i value is now 2 and then j =0 and j&amp;lt;2 so it print i value 2 time and new line&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;Similarly it continue till i &amp;lt; 10. Check the output&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;*/ &lt;/span&gt;&lt;br /&gt;getch();&lt;br /&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;OUTPUT&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwNuhSc24fCqY7W0DRe0NHsHir7Gb9b_UBMhlP7G7-C2-Qajl_7v40zWEpE-eRRbaa2v1Bym5G_OUZsGvzFM5IpHEJbw4p6vojAcnegM1DE8WM45ukjWkAg9VRHSysMYUOArzONUK1G8lm/s1600/nestedloop.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwNuhSc24fCqY7W0DRe0NHsHir7Gb9b_UBMhlP7G7-C2-Qajl_7v40zWEpE-eRRbaa2v1Bym5G_OUZsGvzFM5IpHEJbw4p6vojAcnegM1DE8WM45ukjWkAg9VRHSysMYUOArzONUK1G8lm/s1600/nestedloop.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;- Arshpreet Wadehra
http://twitter.com/wadehrarshpreet&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cplspls.blogspot.com/feeds/6055667203829409251/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://cplspls.blogspot.com/2012/01/using-nested-loop.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7607138261163784346/posts/default/6055667203829409251'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7607138261163784346/posts/default/6055667203829409251'/><link rel='alternate' type='text/html' href='http://cplspls.blogspot.com/2012/01/using-nested-loop.html' title='Using Nested Loop'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwNuhSc24fCqY7W0DRe0NHsHir7Gb9b_UBMhlP7G7-C2-Qajl_7v40zWEpE-eRRbaa2v1Bym5G_OUZsGvzFM5IpHEJbw4p6vojAcnegM1DE8WM45ukjWkAg9VRHSysMYUOArzONUK1G8lm/s72-c/nestedloop.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7607138261163784346.post-2313723244447731170</id><published>2012-01-01T23:13:00.000-08:00</published><updated>2015-08-28T03:45:14.859-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Programs"/><title type='text'>Program : Show Sqaures of Number upto n terms</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Program : Show Sqaures of Number&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;This program first take input from user that an integer value and show the squares of term upto the number that enter by user like if i enter 2 then it display square of 1 and 2 and if i enter any number its show squares upto that term...&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;#include&amp;lt;iostream.h&amp;gt;&lt;b&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;#include&amp;lt;conio.h&amp;gt;&lt;b&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;int main()&lt;b&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;int a; &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&amp;nbsp;cout &amp;lt;&amp;lt; &quot;Enter a Value upto you want to show squares of that number\n&quot;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;cin &amp;gt;&amp;gt; a;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;//Using for Loop&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;for(int i =1; i &amp;lt;=a; i++) &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;cout &amp;lt;&amp;lt; i &amp;lt;&amp;lt; &quot; Square is : &quot; &amp;lt;&amp;lt; i*i &amp;lt;&amp;lt;endl; // show square of that number&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&amp;nbsp;getch();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;return 0;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;&lt;br /&gt;
  &lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;OUTPUT:-&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;I enter Value 10&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&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/AVvXsEgBKE_S4RRbK1tkWSs6W_ZGdcXcrP78h8w19Z7PrwmzpKcV3bKzLU_6MatfLfHV3xn8n3pFIXzuvKQHuZVPDiWaeyxQyEIk7mBYjtLScxZ2WRBoZedWu1VAhY_KkjrK4VQ_etqouUqiFtLF/s1600/out16.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;322&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgBKE_S4RRbK1tkWSs6W_ZGdcXcrP78h8w19Z7PrwmzpKcV3bKzLU_6MatfLfHV3xn8n3pFIXzuvKQHuZVPDiWaeyxQyEIk7mBYjtLScxZ2WRBoZedWu1VAhY_KkjrK4VQ_etqouUqiFtLF/s640/out16.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;&lt;br /&gt;
  &lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;&lt;br /&gt;
  &lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;&lt;br /&gt;
  &lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;- Arshpreet Wadehra
http://twitter.com/wadehrarshpreet&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cplspls.blogspot.com/feeds/2313723244447731170/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://cplspls.blogspot.com/2012/01/program-show-sqaures-of-number-upto-n.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7607138261163784346/posts/default/2313723244447731170'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7607138261163784346/posts/default/2313723244447731170'/><link rel='alternate' type='text/html' href='http://cplspls.blogspot.com/2012/01/program-show-sqaures-of-number-upto-n.html' title='Program : Show Sqaures of Number upto n terms'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgBKE_S4RRbK1tkWSs6W_ZGdcXcrP78h8w19Z7PrwmzpKcV3bKzLU_6MatfLfHV3xn8n3pFIXzuvKQHuZVPDiWaeyxQyEIk7mBYjtLScxZ2WRBoZedWu1VAhY_KkjrK4VQ_etqouUqiFtLF/s72-c/out16.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7607138261163784346.post-3252031029517858701</id><published>2012-01-01T22:58:00.000-08:00</published><updated>2012-01-01T22:59:03.961-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Introduction"/><title type='text'>Introduction to Loop</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Introduction to Loop&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Loop means to repeat again and again. In C++ there are three loops that While loop, do-While loop &amp;amp; For loop. In C++ loop continues while a condition is true. When condition becomes false, the loop ends and control passes to the statements following the loop. &lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;There are three loop as i told before these are&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;For&lt;/b&gt; Loop:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;This loop is easiest C++ loops to understand. This loop contain three parts first initialize , second condition &amp;amp; third increment.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Syntax:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;for(initialize variable; condition ; variable increment)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;like for(int i=0; i &amp;lt; 10; i++)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;In this above statement &#39;i&#39; variable is declared which have value 0 and &#39;i&#39; gave condition that &#39;i&#39; should less than 10 and then increment.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;This works like that at begin its value is 0 and it execute the statement within the braces of for loop then increment is done and condition is check now i = 1 and i &amp;lt; 10 . It again run the code and this go on again and again.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Example :-&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;#include&amp;lt;iostream.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;#include&amp;lt;conio.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;int main()&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;for(int i=1; i &amp;lt;=10; i++) // don&#39;t put semicolon after for loop&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;cout&amp;lt;&amp;lt; i &amp;lt;&amp;lt;endl; // print value of i variable &amp;lt;&amp;lt;endl for new line&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;getch();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;return 0;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Output :&amp;nbsp;&lt;/span&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/AVvXsEgYBEECalOobRuGgMhEYKWMTYl_3yAaQhcHMOLozMIe69HoR6tPlkFK-r4TenE3VXjZaa3_ZRI6Y73jc17clVv6tiLoYGc9UtujY6YD7YaqXJii6Ovl6qhgL7kJg2A_prsRQ5RbSF6iEziI/s1600/ouo.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYBEECalOobRuGgMhEYKWMTYl_3yAaQhcHMOLozMIe69HoR6tPlkFK-r4TenE3VXjZaa3_ZRI6Y73jc17clVv6tiLoYGc9UtujY6YD7YaqXJii6Ovl6qhgL7kJg2A_prsRQ5RbSF6iEziI/s1600/ouo.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;While&lt;/b&gt; Loop&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;While loop is similar to for loop just little difference is there in while loop check the Syntax:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Syntax:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Initialize&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;While(condition)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;statements 1;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;statements 2;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;increment;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;like&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;int i=0;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;while(i&amp;lt;10) //no semicolon&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;statement;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;i++; &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;In Above we initialize &#39;i&#39; value 0 first then while contain condition that i &amp;lt;10and if condition its true then code executes else it skip the loop and continue with program. and here it execute and run the statement 10 times.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Example:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;#include&amp;lt;iostream.h&amp;gt;&lt;br /&gt;#include&amp;lt;conio.h&amp;gt;&lt;br /&gt;int main()&lt;br /&gt;{&lt;br /&gt;int i=1;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;while(i&amp;lt;=10)&lt;br /&gt;{&lt;br /&gt;cout&amp;lt;&amp;lt; i &amp;lt;&amp;lt;endl; // print value of i variable &amp;lt;&amp;lt;endl for new line&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;i++;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;getch();&lt;br /&gt;return 0;&lt;br /&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Output :&amp;nbsp;&lt;/span&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/AVvXsEgYBEECalOobRuGgMhEYKWMTYl_3yAaQhcHMOLozMIe69HoR6tPlkFK-r4TenE3VXjZaa3_ZRI6Y73jc17clVv6tiLoYGc9UtujY6YD7YaqXJii6Ovl6qhgL7kJg2A_prsRQ5RbSF6iEziI/s1600/ouo.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYBEECalOobRuGgMhEYKWMTYl_3yAaQhcHMOLozMIe69HoR6tPlkFK-r4TenE3VXjZaa3_ZRI6Y73jc17clVv6tiLoYGc9UtujY6YD7YaqXJii6Ovl6qhgL7kJg2A_prsRQ5RbSF6iEziI/s1600/ouo.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;And Last&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;do-While&lt;/b&gt; Loop&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Its different from other loop. In this loop Its first initialize then it execute, then increment &amp;amp; last condition is check. My mean to say that Code within do while loop execute at least one time if condition is true or false.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Syntax:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;intialize&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;do&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;statement 1;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;statement 2; &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;increment;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;}while(condition); // semicolon at end&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Check out example:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;#include&amp;lt;iostream.h&amp;gt;&lt;br /&gt;#include&amp;lt;conio.h&amp;gt;&lt;br /&gt;int main()&lt;br /&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;int i=1; // initialize&lt;br /&gt;do&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;cout &amp;lt;&amp;lt; i&amp;lt;&amp;lt;endl; // print i value&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;i++; // increment&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;}while(i&amp;lt;=10); // check condition and semicolon at end&lt;br /&gt;getch();&lt;br /&gt;return 0;&lt;br /&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Output :&amp;nbsp;&lt;/span&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/AVvXsEgYBEECalOobRuGgMhEYKWMTYl_3yAaQhcHMOLozMIe69HoR6tPlkFK-r4TenE3VXjZaa3_ZRI6Y73jc17clVv6tiLoYGc9UtujY6YD7YaqXJii6Ovl6qhgL7kJg2A_prsRQ5RbSF6iEziI/s1600/ouo.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYBEECalOobRuGgMhEYKWMTYl_3yAaQhcHMOLozMIe69HoR6tPlkFK-r4TenE3VXjZaa3_ZRI6Y73jc17clVv6tiLoYGc9UtujY6YD7YaqXJii6Ovl6qhgL7kJg2A_prsRQ5RbSF6iEziI/s1600/ouo.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;- Arshpreet Wadehra
http://twitter.com/wadehrarshpreet&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cplspls.blogspot.com/feeds/3252031029517858701/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://cplspls.blogspot.com/2012/01/introduction-to-loop.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7607138261163784346/posts/default/3252031029517858701'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7607138261163784346/posts/default/3252031029517858701'/><link rel='alternate' type='text/html' href='http://cplspls.blogspot.com/2012/01/introduction-to-loop.html' title='Introduction to Loop'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYBEECalOobRuGgMhEYKWMTYl_3yAaQhcHMOLozMIe69HoR6tPlkFK-r4TenE3VXjZaa3_ZRI6Y73jc17clVv6tiLoYGc9UtujY6YD7YaqXJii6Ovl6qhgL7kJg2A_prsRQ5RbSF6iEziI/s72-c/ouo.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7607138261163784346.post-2013603111860761806</id><published>2011-12-29T00:36:00.000-08:00</published><updated>2015-08-28T03:45:36.760-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Introduction"/><category scheme="http://www.blogger.com/atom/ns#" term="Programs"/><title type='text'>Using Nested Condition</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Using Nested Condition&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Nested&lt;b&gt; &lt;/b&gt;Condition is if else condition that is used under if or else condition. Its condition within condition. Like : We have to check Something Like Someone DOB First i check date then Month and Then Year Three Statement check in One Condition.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Check out One Example For Better Understand.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;#include&amp;lt;iostream.h&amp;gt;&lt;br /&gt;&lt;br /&gt;#include&amp;lt;conio.h&amp;gt;&lt;br /&gt;&lt;br /&gt;int main()&lt;br /&gt;&lt;br /&gt;{ &lt;br /&gt;int number;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;cout &amp;lt;&amp;lt; &quot;Enter Any Number\n&quot;;&lt;br /&gt;cin &amp;gt;&amp;gt; number;&lt;br /&gt;&lt;br /&gt;if(number &amp;gt;10) // check number greater than 10&lt;br /&gt;{&lt;br /&gt;if(number &amp;lt;100)&amp;nbsp;&amp;nbsp;&amp;nbsp; // check number less than 100&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cout &amp;lt;&amp;lt; &quot;Number is Between 10-100&quot;;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;else&lt;br /&gt;{&lt;br /&gt;if(number&amp;lt;10) // check number less than 10&lt;br /&gt;{&lt;br /&gt;cout &amp;lt;&amp;lt; &quot;Number is less than 10&quot;;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;getch();&lt;br /&gt;&lt;br /&gt;return 0;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;OUTPUT&lt;/span&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/AVvXsEie-XdTSAFCobGpE0hX6LjHBILw09jKutKfazQggnD0oUKMJN7XBzhdzq0wcd2YqrWGrLlj663UfMgCooAN_X9tWMsFFt9AkHvPLyBqCvbByI-sjq6JbYQtol8zuUjxC9yKBdpmaSpCexnh/s1600/out15.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;162&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEie-XdTSAFCobGpE0hX6LjHBILw09jKutKfazQggnD0oUKMJN7XBzhdzq0wcd2YqrWGrLlj663UfMgCooAN_X9tWMsFFt9AkHvPLyBqCvbByI-sjq6JbYQtol8zuUjxC9yKBdpmaSpCexnh/s640/out15.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;- Arshpreet Wadehra
http://twitter.com/wadehrarshpreet&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cplspls.blogspot.com/feeds/2013603111860761806/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://cplspls.blogspot.com/2011/12/using-nested-condition.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7607138261163784346/posts/default/2013603111860761806'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7607138261163784346/posts/default/2013603111860761806'/><link rel='alternate' type='text/html' href='http://cplspls.blogspot.com/2011/12/using-nested-condition.html' title='Using Nested Condition'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEie-XdTSAFCobGpE0hX6LjHBILw09jKutKfazQggnD0oUKMJN7XBzhdzq0wcd2YqrWGrLlj663UfMgCooAN_X9tWMsFFt9AkHvPLyBqCvbByI-sjq6JbYQtol8zuUjxC9yKBdpmaSpCexnh/s72-c/out15.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7607138261163784346.post-7142022391212844416</id><published>2011-12-29T00:04:00.000-08:00</published><updated>2015-08-28T03:45:58.266-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Introduction"/><category scheme="http://www.blogger.com/atom/ns#" term="Programs"/><title type='text'>Using else if statement</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Using else if statement&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Else if statement is similar to &lt;a href=&quot;http://cplspls.blogspot.com/2011/12/using-conditional-statements.html&quot; target=&quot;_blank&quot;&gt;if condition&lt;/a&gt;. In else-if condition you can give more than one condition like we have to give grade if students score greater than 90 got A grade, b/w 70-90 got B grade , 50-70 got C grade and so on. it require more than one condition. So we use else if condition check out example for better understand.&lt;/span&gt; &lt;br /&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;#include&amp;lt;iostream.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;#include&amp;lt;conio.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;int main()&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;{&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;int eng,sc,maths;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;float percentage;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;cout &amp;lt;&amp;lt; &quot;Enter Marks of student in\n&quot;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;cout &amp;lt;&amp;lt; &quot;In english \n&quot;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;cin&amp;gt;&amp;gt; eng;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;cout &amp;lt;&amp;lt; &quot;In Science\n&quot;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;cin&amp;gt;&amp;gt;sc;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;cout &amp;lt;&amp;lt;&quot;In maths\n&quot;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;cin &amp;gt;&amp;gt; maths;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;percentage = (sc+maths+eng)/3; // %age formula (total / 300) * 100&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;if(percentage &amp;gt; 90) // check condition&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;cout &amp;lt;&amp;lt; &quot;A Grade\n&quot;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;else if(percentage &amp;gt; 70)//similar to if also check condition&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;cout &amp;lt;&amp;lt; &quot;B Grade\n&quot;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;else if(percentage &amp;gt; 50)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;cout&amp;lt;&amp;lt; &quot; C Grade\n&quot;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;else if(percentage &amp;gt; 40)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;cout &amp;lt;&amp;lt; &quot;D Grade\n&quot;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;else&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;cout &amp;lt;&amp;lt; &quot;E Grade\n&quot;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;getch();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;return 0;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;OUTPUT&lt;/b&gt;&lt;/span&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/AVvXsEjpqY2tqJvJnyUeUIAExKG2b9N6-GedtKtyNYww4feEJymAiHk9Bc38FyvGZe4ChyphenhyphenS6pNtrXhZranqGwH5SOJpov7nWeJXviyRb-V6-WSsbSDuf87FNc84XiZrWM8GFyVjqxGA_5xe3Le5V/s1600/out14.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;252&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjpqY2tqJvJnyUeUIAExKG2b9N6-GedtKtyNYww4feEJymAiHk9Bc38FyvGZe4ChyphenhyphenS6pNtrXhZranqGwH5SOJpov7nWeJXviyRb-V6-WSsbSDuf87FNc84XiZrWM8GFyVjqxGA_5xe3Le5V/s640/out14.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;- Arshpreet Wadehra
http://twitter.com/wadehrarshpreet&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cplspls.blogspot.com/feeds/7142022391212844416/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://cplspls.blogspot.com/2011/12/using-else-if-statement.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7607138261163784346/posts/default/7142022391212844416'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7607138261163784346/posts/default/7142022391212844416'/><link rel='alternate' type='text/html' href='http://cplspls.blogspot.com/2011/12/using-else-if-statement.html' title='Using else if statement'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjpqY2tqJvJnyUeUIAExKG2b9N6-GedtKtyNYww4feEJymAiHk9Bc38FyvGZe4ChyphenhyphenS6pNtrXhZranqGwH5SOJpov7nWeJXviyRb-V6-WSsbSDuf87FNc84XiZrWM8GFyVjqxGA_5xe3Le5V/s72-c/out14.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7607138261163784346.post-5023153120617108647</id><published>2011-12-28T04:45:00.000-08:00</published><updated>2015-08-28T03:47:09.234-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Introduction"/><category scheme="http://www.blogger.com/atom/ns#" term="Programs"/><title type='text'>Using Conditional Statements</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Using Conditional Statements&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;The if statement is used to check the condition. If Condition is true Then particular code execute and if condition is not true then it pass to else statement, and that code is execute within else. &amp;amp; else statement is not necessary every time. Check Out One Program to better Understand&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;#include&amp;lt;iostream.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;#include&amp;lt;conio.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;int main()&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;int a; &lt;span style=&quot;color: #6aa84f;&quot;&gt;//a integer variable define&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;cout &amp;lt;&amp;lt; &quot;Enter Any Number\n&quot;; &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;cin &amp;gt;&amp;gt; a;&lt;span style=&quot;color: #6aa84f;&quot;&gt; // take value in a&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;if(a%2 == 0)&amp;nbsp; //check if a%2 == 0 then code execute&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;color: #6aa84f;&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;/* a%2 means value of a divide by 2 and if the remainder comes out to be zero then its display its Even Number.&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;{ &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;cout &amp;lt;&amp;lt; &quot;Its Even Number\n&quot;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;}&lt;span style=&quot;color: #6aa84f;&quot;&gt; // code should be written in braces&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;else&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;color: #6aa84f;&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;/* Else Dont Require any argument So you need to type else only and rest of code that execute if, if statement is false&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #6aa84f;&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Here if a%2 is other than 0 then its show Its Odd Number.&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;cout &amp;lt;&amp;lt; &quot;Its Odd Number\n&quot;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;getch();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;return 0;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;OUTPUT&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjRxpeZcEuoSKdkvACgZhfH8tKgfIUo0N23o9Wn4XsEyRkjkg03f1e34j2hHr9qo8YOw4ECviRsR2iKuzzzZ9UU2HsLzQu98Xjv8H9-UvGjivpNJVOoulCFradmPZm2KYieSoOdHcAjha1P/s1600/ifelse.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;95&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjRxpeZcEuoSKdkvACgZhfH8tKgfIUo0N23o9Wn4XsEyRkjkg03f1e34j2hHr9qo8YOw4ECviRsR2iKuzzzZ9UU2HsLzQu98Xjv8H9-UvGjivpNJVOoulCFradmPZm2KYieSoOdHcAjha1P/s320/ifelse.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;a href=&quot;http://draft.blogger.com/goog_268957387&quot;&gt;&lt;br /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;- Arshpreet Wadehra
http://twitter.com/wadehrarshpreet&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cplspls.blogspot.com/feeds/5023153120617108647/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://cplspls.blogspot.com/2011/12/using-conditional-statements.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7607138261163784346/posts/default/5023153120617108647'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7607138261163784346/posts/default/5023153120617108647'/><link rel='alternate' type='text/html' href='http://cplspls.blogspot.com/2011/12/using-conditional-statements.html' title='Using Conditional Statements'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjRxpeZcEuoSKdkvACgZhfH8tKgfIUo0N23o9Wn4XsEyRkjkg03f1e34j2hHr9qo8YOw4ECviRsR2iKuzzzZ9UU2HsLzQu98Xjv8H9-UvGjivpNJVOoulCFradmPZm2KYieSoOdHcAjha1P/s72-c/ifelse.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7607138261163784346.post-8160528312748526866</id><published>2011-12-20T05:41:00.000-08:00</published><updated>2015-08-28T03:47:50.633-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Built in Functions"/><category scheme="http://www.blogger.com/atom/ns#" term="Programs"/><title type='text'>Program : Using #define Function</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Using #define Function&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;#define &lt;/b&gt;use to define a function or value or any work that particular keyword replace with that work like to display on screen i always use cout &amp;lt;&amp;lt; everytime i replace it with a keyword print so next time when i require cout &amp;lt;&amp;lt; then i have to use only print rest all is same like print &quot;AZ&quot;; //it will print AZ. Check Out Program.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Let Check Out Example :-&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;//Using #define function&lt;/span&gt;&lt;br /&gt;
#include&amp;lt;iostream.h&amp;gt;&lt;br /&gt;
#include&amp;lt;conio.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#define pi 3.14&lt;br /&gt;
&lt;span style=&quot;color: #6aa84f;&quot;&gt;/* Here i Define a Variable pi which i assign a value that 3.14(here)&lt;/span&gt;&lt;br style=&quot;color: #6aa84f;&quot; /&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;*/&lt;/span&gt;&lt;br /&gt;
#define print cout &amp;lt;&amp;lt;&lt;br /&gt;
&lt;span style=&quot;color: #6aa84f;&quot;&gt;/* It must declare after Header File &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #6aa84f;&quot;&gt;Syntax :-&lt;/span&gt;&lt;br style=&quot;color: #6aa84f;&quot; /&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;#define variable_name function or value&lt;/span&gt;&lt;br style=&quot;color: #6aa84f;&quot; /&gt;&lt;br style=&quot;color: #6aa84f;&quot; /&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;Like here i define variable print which function is to replace cout &amp;lt;&amp;lt;&lt;/span&gt;&lt;br style=&quot;color: #6aa84f;&quot; /&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;So i dont have to write cout &amp;lt;&amp;lt; i can write directly print check out main function*/&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
print pi; // print = cout &amp;lt;&amp;lt; and pi = 3.14&lt;br /&gt;
&lt;span style=&quot;color: #6aa84f;&quot;&gt;// it will print 3.14 on screen&lt;/span&gt;&lt;br /&gt;
print &quot;\nHello world&quot;; &lt;span style=&quot;color: #6aa84f;&quot;&gt;// print hello world&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;getch();&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;return 0;&lt;br /&gt;
}&lt;/span&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt; &lt;br /&gt;
&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Output&lt;/span&gt;&lt;/b&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;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjeoMc-C1Aaw7CRpiIm48mbwr1e4s4LNqoNYMIAnDIbGibgbWXC_9cVmO6bkPAzDq3GqwvU2HFJNurP_1TCTWy-LFZUCo5st85sguyLl0Lr_BlzPp4uWvdzFhyphenhyphenAXCA5wUODfLI_BiQWVM2v/s1600/out12.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;322&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjeoMc-C1Aaw7CRpiIm48mbwr1e4s4LNqoNYMIAnDIbGibgbWXC_9cVmO6bkPAzDq3GqwvU2HFJNurP_1TCTWy-LFZUCo5st85sguyLl0Lr_BlzPp4uWvdzFhyphenhyphenAXCA5wUODfLI_BiQWVM2v/s640/out12.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;- Arshpreet Wadehra
http://twitter.com/wadehrarshpreet&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cplspls.blogspot.com/feeds/8160528312748526866/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://cplspls.blogspot.com/2011/12/program-using-define-function.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7607138261163784346/posts/default/8160528312748526866'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7607138261163784346/posts/default/8160528312748526866'/><link rel='alternate' type='text/html' href='http://cplspls.blogspot.com/2011/12/program-using-define-function.html' title='Program : Using #define Function'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjeoMc-C1Aaw7CRpiIm48mbwr1e4s4LNqoNYMIAnDIbGibgbWXC_9cVmO6bkPAzDq3GqwvU2HFJNurP_1TCTWy-LFZUCo5st85sguyLl0Lr_BlzPp4uWvdzFhyphenhyphenAXCA5wUODfLI_BiQWVM2v/s72-c/out12.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7607138261163784346.post-5867209620746459213</id><published>2011-12-20T05:34:00.000-08:00</published><updated>2015-08-28T03:48:09.408-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Introduction"/><category scheme="http://www.blogger.com/atom/ns#" term="Programs"/><title type='text'>Program : Using Bool Data Type</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Using Bool Data Type&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;B&lt;/b&gt;ool data type can store two value only 0 or 1. o for False &amp;amp; 1 For True. if define Bool variable and that variable contain value more than 1 it store only 1 like i declare bool variable az = 1212313; it store az = 1 or az = true; it store az =1 &amp;amp; it shows zero when its False or value is Zero only.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Let Check Out Example :-&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;#include&amp;lt;iostream.h&amp;gt;&lt;br /&gt;
#include&amp;lt;conio.h&amp;gt;&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Using Bool Data Type&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; bool a = 321, b; &lt;span style=&quot;color: #6aa84f;&quot;&gt;/*Declare two bool variable. Bool store two type of value true or falue and this show &lt;/span&gt;&lt;br style=&quot;color: #6aa84f;&quot; /&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;bu integer value 1 for true and 0 for false like here i initialize bool a&lt;/span&gt;&lt;br style=&quot;color: #6aa84f;&quot; /&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;with 321 value it store 1 in it let see*/&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; cout &amp;lt;&amp;lt; &quot;Bool a Contains : &quot; &amp;lt;&amp;lt; a;&lt;span style=&quot;color: #6aa84f;&quot;&gt; // print a it show 1&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; int c = true; &lt;span style=&quot;color: #6aa84f;&quot;&gt;// it store value 1 for true and 0 for false&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; c = a + a;&lt;span style=&quot;color: #6aa84f;&quot;&gt; // a value is 1 and 1 add to 1 gives 2&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; cout &amp;lt;&amp;lt; &quot;\nInteger c contain : &quot; &amp;lt;&amp;lt; c; //print c value &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; b = c + a;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;/* it 2 + 1 it give 1 because its type is bool so it show only 0 and 1*/&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; cout &amp;lt;&amp;lt; &quot;\nBool b contain : &quot; &amp;lt;&amp;lt;b;&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; getch();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; return 0;&lt;br /&gt;
}&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt; &lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt; &lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Output&lt;/span&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/AVvXsEj6cByKkZ9M-IMAZt8Z07IQ85x0WFmpKgsN83s5eCXCtxemhexGLOezekHa42xDW5XWAPLEbkt8Sj4t3y5bYRVtqf4QAuDjRTx0coklhALXl-lU7zDImeBdHjuK34MXebS58-2sTOmUtizy/s1600/out11.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;322&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj6cByKkZ9M-IMAZt8Z07IQ85x0WFmpKgsN83s5eCXCtxemhexGLOezekHa42xDW5XWAPLEbkt8Sj4t3y5bYRVtqf4QAuDjRTx0coklhALXl-lU7zDImeBdHjuK34MXebS58-2sTOmUtizy/s640/out11.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;- Arshpreet Wadehra
http://twitter.com/wadehrarshpreet&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cplspls.blogspot.com/feeds/5867209620746459213/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://cplspls.blogspot.com/2011/12/program-using-bool-data-type.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7607138261163784346/posts/default/5867209620746459213'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7607138261163784346/posts/default/5867209620746459213'/><link rel='alternate' type='text/html' href='http://cplspls.blogspot.com/2011/12/program-using-bool-data-type.html' title='Program : Using Bool Data Type'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj6cByKkZ9M-IMAZt8Z07IQ85x0WFmpKgsN83s5eCXCtxemhexGLOezekHa42xDW5XWAPLEbkt8Sj4t3y5bYRVtqf4QAuDjRTx0coklhALXl-lU7zDImeBdHjuK34MXebS58-2sTOmUtizy/s72-c/out11.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7607138261163784346.post-3169881588986523543</id><published>2011-12-16T05:39:00.000-08:00</published><updated>2015-08-28T03:48:22.231-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Introduction"/><category scheme="http://www.blogger.com/atom/ns#" term="Programs"/><title type='text'>Assignment &amp; Increment/Decrement Operators</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Assignment &amp;amp; Increment/Decrement Operators&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;This operators are used to shorten the code. Assignment Operators are used to assign value with arithmetic operators &amp;amp; Increment or Decrement used to increase by 1 or decrease by 1 using ++ or -- sign&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;you can learn more check out following program:-&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;#include&amp;lt;iostream.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;#include&amp;lt;conio.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;int main()&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;int a = 10, b = 20; // declare and assign value to variable&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;a += b; // this means a = a + b&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;cout &amp;lt;&amp;lt; a&lt;/span&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&amp;lt;&amp;lt;endl&lt;/span&gt;&lt;span style=&quot;font-size: large;&quot;&gt;;&amp;nbsp; // print 30&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;a -= b; // this means&amp;nbsp; a = a - b&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;cout &amp;lt;&amp;lt; a&lt;/span&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&amp;lt;&amp;lt;endl&lt;/span&gt;&lt;span style=&quot;font-size: large;&quot;&gt;; // print 10&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;a *= b; // this means&amp;nbsp; a = a * b&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;cout &amp;lt;&amp;lt; a&lt;/span&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&amp;lt;&amp;lt;endl&lt;/span&gt;&lt;span style=&quot;font-size: large;&quot;&gt;; // print 200&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;a /= b; // this means&amp;nbsp; a = a / b&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;cout &amp;lt;&amp;lt; a &amp;lt;&amp;lt;endl; // print 10&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
//using Increment and Decrement Operators&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;a++;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;cout &amp;lt;&amp;lt; a&lt;/span&gt;&lt;span style=&quot;font-size: large;&quot;&gt; &amp;lt;&amp;lt;endl&lt;/span&gt;&lt;span style=&quot;font-size: large;&quot;&gt;;&amp;nbsp;&amp;nbsp; // print 11&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;cout &amp;lt;&amp;lt; a++&lt;/span&gt;&lt;span style=&quot;font-size: large;&quot;&gt; &amp;lt;&amp;lt;endl&lt;/span&gt;&lt;span style=&quot;font-size: large;&quot;&gt;;&amp;nbsp;&amp;nbsp; // print 11&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;cout &amp;lt;&amp;lt; a &lt;/span&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&amp;lt;&amp;lt;endl&lt;/span&gt;&lt;span style=&quot;font-size: large;&quot;&gt;;&amp;nbsp;&amp;nbsp; //print 12&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;cout &amp;lt;&amp;lt; ++a &lt;/span&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&amp;lt;&amp;lt;endl&lt;/span&gt;&lt;span style=&quot;font-size: large;&quot;&gt;;&amp;nbsp;&amp;nbsp; // print 13&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;/* AS you see last four line as i cout a it shows 11 when i use a++ then also its shows 11 this is because when we use a++ its value remain same at that part or that time of declaration. This is known as post-increment. It Increase Value by 1 later of declaration. Like here after cout a++ on next line i cout &amp;lt;&amp;lt; a; its shows value of a with 1 increment. &amp;amp; after that i use ++a this is pre-increment and this increase value by 1 at the same time it show 13*/&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;a--; // now a = 13&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;cout &amp;lt;&amp;lt; a&lt;/span&gt;&lt;span style=&quot;font-size: large;&quot;&gt; &amp;lt;&amp;lt;endl&lt;/span&gt;&lt;span style=&quot;font-size: large;&quot;&gt;;&amp;nbsp;&amp;nbsp; // print 12&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;cout &amp;lt;&amp;lt; a--&lt;/span&gt;&lt;span style=&quot;font-size: large;&quot;&gt; &amp;lt;&amp;lt;endl&lt;/span&gt;&lt;span style=&quot;font-size: large;&quot;&gt;;&amp;nbsp;&amp;nbsp; // print 12&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;cout &amp;lt;&amp;lt; a &lt;/span&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&amp;lt;&amp;lt;endl&lt;/span&gt;&lt;span style=&quot;font-size: large;&quot;&gt;;&amp;nbsp;&amp;nbsp; //print 11&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;cout &amp;lt;&amp;lt; --a &lt;/span&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&amp;lt;&amp;lt;endl&lt;/span&gt;&lt;span style=&quot;font-size: large;&quot;&gt;;&amp;nbsp;&amp;nbsp; // print 10&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&amp;nbsp;/* Here also concept is same of increment but difference is that there is increase by 1 but here decrease by 1 with same concept&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;*/&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;getch();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;return 0;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;OUTPUT&lt;/b&gt;&lt;/span&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/AVvXsEjuuLSaZfduOSR82hcfGSq7jznOQJeqbdQhH-QQrhGWUVskhtg7xEgyxoIIVMxPuVM5Faol9ZM9CtQh-UBSwfgGolTkRlBKIiDt6onvvcSK1u-XpAjag1cXG03vXKvDKc4U03mGjycVKCaQ/s1600/out10.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;322&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuuLSaZfduOSR82hcfGSq7jznOQJeqbdQhH-QQrhGWUVskhtg7xEgyxoIIVMxPuVM5Faol9ZM9CtQh-UBSwfgGolTkRlBKIiDt6onvvcSK1u-XpAjag1cXG03vXKvDKc4U03mGjycVKCaQ/s640/out10.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;- Arshpreet Wadehra
http://twitter.com/wadehrarshpreet&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cplspls.blogspot.com/feeds/3169881588986523543/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://cplspls.blogspot.com/2011/12/assignment-incrementdecrement-operators.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7607138261163784346/posts/default/3169881588986523543'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7607138261163784346/posts/default/3169881588986523543'/><link rel='alternate' type='text/html' href='http://cplspls.blogspot.com/2011/12/assignment-incrementdecrement-operators.html' title='Assignment &amp; Increment/Decrement Operators'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuuLSaZfduOSR82hcfGSq7jznOQJeqbdQhH-QQrhGWUVskhtg7xEgyxoIIVMxPuVM5Faol9ZM9CtQh-UBSwfgGolTkRlBKIiDt6onvvcSK1u-XpAjag1cXG03vXKvDKc4U03mGjycVKCaQ/s72-c/out10.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7607138261163784346.post-8171926268714143543</id><published>2011-12-16T03:53:00.000-08:00</published><updated>2015-08-28T03:48:36.823-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Programs"/><title type='text'>Program : Using Arithmetic Operators</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Program : Using Arithmetic Operators&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Arithmetic Operators&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;There are mainly Four Arithmetic Operators in C++ i.e. are + , - , *&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt; &lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt; /&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;. + for Addition , - for Subtraction , * for Multiply &amp;amp; / for Divide.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Check the Following Program :-&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;#include&amp;lt;iostream.h&amp;gt;&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;#include&amp;lt;conio.h&amp;gt;&amp;nbsp; &lt;span style=&quot;color: #6aa84f;&quot;&gt;// for getch()&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;int main()&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;float a , b; &lt;span style=&quot;color: #6aa84f;&quot;&gt;// define float variable &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;cout &amp;lt;&amp;lt; &quot;Enter 1st Number \n&quot;;&amp;nbsp; &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;cin &amp;gt;&amp;gt; a; // take value in a variable&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;cout &amp;lt;&amp;lt; &quot;Enter 2nd Number \n&quot;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;cin &amp;gt;&amp;gt; b; //take value in b variable&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;cout &amp;lt;&amp;lt; &quot;Addition = &quot; &amp;lt;&amp;lt; a + b &amp;lt;&amp;lt;endl; &lt;span style=&quot;color: #6aa84f;&quot;&gt;/* Display Addition value of a &amp;amp; b variable*/&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;cout &amp;lt;&amp;lt; &quot;Subtraction = &quot; &amp;lt;&amp;lt; a - b &amp;lt;&amp;lt;endl; &lt;span style=&quot;color: #6aa84f;&quot;&gt;/&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;*&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt; Display Subtracted value of a &amp;amp; b variable&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;cout &amp;lt;&amp;lt; &quot;Multiply = &quot; &amp;lt;&amp;lt; a * b &amp;lt;&amp;lt;endl; &lt;span style=&quot;color: #6aa84f;&quot;&gt;/&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;*&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt; Display Multiply value of a &amp;amp; b variable&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;cout &amp;lt;&amp;lt; &quot;Divide = &quot; &amp;lt;&amp;lt; a / b &amp;lt;&amp;lt;endl; &lt;span style=&quot;color: #6aa84f;&quot;&gt;/* Display &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #6aa84f; font-size: large;&quot;&gt;Divided&lt;/span&gt;&lt;span style=&quot;color: #6aa84f; font-size: large;&quot;&gt; value of a &amp;amp; b variable&lt;/span&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: large;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;getch();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;return 0;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;OUTPUT&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&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/AVvXsEj0sl6JXgFTOsIzNbyfMw_Z0lAbEV_4DFVqFKX-sqVPphsEfIgJge-DN2ss5kzujOu7grCUuLp3qzTuxk0hhkp6hUjHElZBecmSTMd2yakHZKYw3sQI2Wq4xj7e27VVQLKEmTfoRZyGkAUM/s1600/out9.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;322&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj0sl6JXgFTOsIzNbyfMw_Z0lAbEV_4DFVqFKX-sqVPphsEfIgJge-DN2ss5kzujOu7grCUuLp3qzTuxk0hhkp6hUjHElZBecmSTMd2yakHZKYw3sQI2Wq4xj7e27VVQLKEmTfoRZyGkAUM/s640/out9.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;- Arshpreet Wadehra
http://twitter.com/wadehrarshpreet&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cplspls.blogspot.com/feeds/8171926268714143543/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://cplspls.blogspot.com/2011/12/program-using-arithmetic-operators.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7607138261163784346/posts/default/8171926268714143543'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7607138261163784346/posts/default/8171926268714143543'/><link rel='alternate' type='text/html' href='http://cplspls.blogspot.com/2011/12/program-using-arithmetic-operators.html' title='Program : Using Arithmetic Operators'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj0sl6JXgFTOsIzNbyfMw_Z0lAbEV_4DFVqFKX-sqVPphsEfIgJge-DN2ss5kzujOu7grCUuLp3qzTuxk0hhkp6hUjHElZBecmSTMd2yakHZKYw3sQI2Wq4xj7e27VVQLKEmTfoRZyGkAUM/s72-c/out9.png" height="72" width="72"/><thr:total>0</thr:total></entry></feed>