<?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-6893346382604416070</id><updated>2015-04-11T05:06:03.735-07:00</updated><category term="Algorithm"/><category term="Simple programs"/><category term="Sorting"/><category term="Example"/><category term="Datatypes and Variables"/><category term="Examples"/><category term="Time Complexity"/><category term="Array"/><category term="Bubble Sort"/><category term="Divide and Conquer"/><category term="Insertion Sort"/><category term="Linked List"/><title type='text'>ProgramsWay: Learn C Programming in an Easy Way</title><subtitle type='html'>Programsway.com</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://www.programsway.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6893346382604416070/posts/default'/><link rel='alternate' type='text/html' href='http://www.programsway.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Wyes Karny</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-b---zWeiKtw/AAAAAAAAAAI/AAAAAAAAA3Y/IEVnupjQoh8/s512-c/photo.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>24</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6893346382604416070.post-7564099726051868808</id><published>2014-03-12T00:10:00.000-07:00</published><updated>2014-03-12T00:10:48.334-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Algorithm"/><category scheme="http://www.blogger.com/atom/ns#" term="Bubble Sort"/><category scheme="http://www.blogger.com/atom/ns#" term="Simple programs"/><category scheme="http://www.blogger.com/atom/ns#" term="Sorting"/><title type='text'>C Program to sort n numbers using Bubble Sort algorithm</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;&lt;br /&gt;&lt;br /&gt;#include&amp;lt;stdio.h&amp;gt;&lt;br /&gt;#include&amp;lt;stdlib.h&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;int *a,n;&lt;br /&gt;void bubblesort();&lt;br /&gt;void swap_w(int,int);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;main()&lt;br /&gt;{&lt;br /&gt; int i,j;&lt;br /&gt; printf(&quot;Enter the number of elements &quot;);&lt;br /&gt; scanf(&quot;%d&quot;,&amp;amp;n);&lt;br /&gt; a=(int *)calloc(n,sizeof(int));&lt;br /&gt; printf(&quot;Enter the elements\n&quot;);&lt;br /&gt; for(i=0;i&amp;lt;n;i++)&lt;br /&gt; scanf(&quot;%d&quot;,a+i);&lt;br /&gt; bubblesort(0,n-1);&lt;br /&gt; printf(&quot;The sorted sequence is\n&quot;);&lt;br /&gt; for(i=0;i&amp;lt;n;i++)&lt;br /&gt; printf(&quot;%d &quot;,a[i]);&lt;br /&gt; printf(&quot;\n&quot;);&lt;br /&gt; return;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;void bubblesort()&lt;br /&gt;{&lt;br /&gt; int i,j;&lt;br /&gt; for(i=0;i&amp;lt;n-1;i++)&lt;br /&gt; for(j=n-1;j&amp;gt;=i+1;j--)&lt;br /&gt; if(a[j]&amp;lt;a[j-1])&lt;br /&gt; swap_w(j,j-1);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;void swap_w(int i,int j)&lt;br /&gt;{&lt;br /&gt; int temp;&lt;br /&gt; temp=a[i];&lt;br /&gt; a[i]=a[j];&lt;br /&gt; a[j]=temp;&lt;br /&gt; return;&lt;br /&gt;}&lt;/blockquote&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.programsway.com/feeds/7564099726051868808/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.programsway.com/2014/03/c-program-to-sort-n-numbers-using.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6893346382604416070/posts/default/7564099726051868808'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6893346382604416070/posts/default/7564099726051868808'/><link rel='alternate' type='text/html' href='http://www.programsway.com/2014/03/c-program-to-sort-n-numbers-using.html' title='C Program to sort n numbers using Bubble Sort algorithm'/><author><name>Wyes Karny</name><uri>https://plus.google.com/110965746277342011781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-b---zWeiKtw/AAAAAAAAAAI/AAAAAAAAA3Y/IEVnupjQoh8/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6893346382604416070.post-532799138502643108</id><published>2014-01-09T07:30:00.001-08:00</published><updated>2014-01-09T07:30:45.204-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Array"/><category scheme="http://www.blogger.com/atom/ns#" term="Datatypes and Variables"/><category scheme="http://www.blogger.com/atom/ns#" term="Example"/><category scheme="http://www.blogger.com/atom/ns#" term="Examples"/><title type='text'>ARRAYS IN C</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: #6aa84f;&quot;&gt;Written by Kousik : &lt;/span&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;C provides some fundamental &lt;b&gt;DATA&lt;/b&gt; types. They are &lt;b&gt;int&lt;/b&gt;, &lt;b&gt;float&lt;/b&gt;, &lt;b&gt;char&lt;/b&gt;, &lt;b&gt;double&lt;/b&gt;. They are very useful and important in C language. But they have a limiting fact. The fact is that a variable of these types can store only one value at a time. With variables of those types we cannot handle a large volume of data of same type at a time. So we need a powerful data type with which we can solve this problem. C supports such a data type called &lt;b&gt;ARRAYS&lt;/b&gt;.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot;&gt;Definition&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot;&gt;: An array is a well defined collection of elements of same data type. In others words One can say that an array is grouping of some elements that are of same data type. Some applications of arrays in C are given below:&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpFirst&quot; style=&quot;mso-list: l0 level1 lfo1; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Wingdings; mso-bidi-font-family: Wingdings; mso-fareast-font-family: Wingdings;&quot;&gt;§&lt;span style=&quot;font-family: &#39;Times New Roman&#39;; font-size: 7pt;&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot;&gt;To store age of some boys.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;mso-list: l0 level1 lfo1; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Wingdings; mso-bidi-font-family: Wingdings; mso-fareast-font-family: Wingdings;&quot;&gt;§&lt;span style=&quot;font-family: &#39;Times New Roman&#39;; font-size: 7pt;&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot;&gt;To store marks of subjects.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpLast&quot; style=&quot;mso-list: l0 level1 lfo1; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Wingdings; mso-bidi-font-family: Wingdings; mso-fareast-font-family: Wingdings;&quot;&gt;§&lt;span style=&quot;font-family: &#39;Times New Roman&#39;; font-size: 7pt;&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot;&gt;To store daily rainfall data. &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;And so on.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot;&gt;Declaration of ARRAYS&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot;&gt;: &amp;nbsp;ARRAY in C can be declared by following format&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;int array[50]; , float temperature[7];&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;See carefully that an array is declared by defining the data type first then the name and then the &amp;nbsp;size of array.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;Now a question should be come to reader’s mind and that is how can we take input of many elements at a time by using array? Answer of this question is very easy. This problem can be solved by using for loop for taking input by using following syntax.&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;For (i=0; i&amp;lt;n; i++)&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;Scanf (“%d”, &amp;amp;arr[i]);&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;Where n is the size of the array and arr is the name of array.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;Now here a example is given to understand ARRAYS and the way of using an ARRAY in C.&lt;/span&gt;&lt;/div&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;&lt;br /&gt;&lt;br /&gt;#include&amp;lt;stdio.h&amp;gt;&lt;br /&gt;int main()&lt;br /&gt;{&lt;br /&gt;   int a[25],i,n,sum=0,mean;&lt;br /&gt;   printf(&quot;Enter the number of array elements\n&quot;);&lt;br /&gt;   scanf(&quot;%d&quot;,&amp;amp;n);&lt;br /&gt;   printf(&quot;Enter the value of array elements\n&quot;);&lt;br /&gt;   for(i=0;i&amp;lt;n;i++)&lt;br /&gt;   {&lt;br /&gt;     scanf(&quot;%d&quot;,&amp;amp;a[i]);&lt;br /&gt;   }&lt;br /&gt;  for(i=0;i&amp;lt;n;i++)&lt;br /&gt;  {&lt;br /&gt;   Printf(“%d ”, a[i]);&lt;br /&gt;  }&lt;br /&gt;  return 0;&lt;br /&gt;}&lt;/blockquote&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;There are two kinds of array those can be used in C language. One is &lt;b&gt;ONE DIMENSIONAL&lt;/b&gt; and the other one is &lt;b&gt;TWO DIMENSIONAL&lt;/b&gt;.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;In this section we will discuss about only one dimensional array.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot;&gt;INITIALIZATION OF ONE DIMENSIONAL ARRAY&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot;&gt;: After declaring an array its elements can be initialized. Otherwise elements of array are of ‘garbage’. The following syntax can be used to initialize an array.&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;Data type&amp;nbsp; variablename[size]={values};&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;Example : int student[3]={1,2,3};&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;Above example is called compile time initialization. Another type of initialization can be used for initialize an array. That is Run time initialization. For example take the following segment.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp; for(j=0;j&amp;lt;50;j++)&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp; {&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; If(j&amp;lt;20)&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp; A[i]=0.0;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp; Else&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp; A[i]=1.0;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp; }&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;We can also use a scanf function to initialize an array as we discuss earlier with the answer of the question how to take input value of elements of an array.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;The following example illustrates a sorting program in ascending order as an important application of arrays in C science.&lt;/span&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;br /&gt;&lt;br /&gt;/* a program to sort an array */&lt;br /&gt;# include&amp;lt;stdio.h&amp;gt;&lt;br /&gt;int main()&lt;br /&gt;{&lt;br /&gt;  int a[25],i,j,n,temp,item;&lt;br /&gt;  char c;&lt;br /&gt;  printf(&quot;Enter the number of array elements\n&quot;);&lt;br /&gt;  scanf(&quot;%d&quot;,&amp;amp;n);&lt;br /&gt;  printf(&quot;Enter the value of array elements\n&quot;);&lt;br /&gt;  for(i=0;i&amp;lt;n;i++)&lt;br /&gt;  {&lt;br /&gt;    scanf(&quot;%d&quot;,&amp;amp;a[i]);&lt;br /&gt;  }&lt;br /&gt;  /* sorting of array */&lt;br /&gt;  for(i=0;i&amp;lt;n;i++)&lt;br /&gt;  {&lt;br /&gt;   for(j=i+1;j&amp;lt;n;j++)&lt;br /&gt;   {&lt;br /&gt;     if(a[i]&amp;gt;a[j])&lt;br /&gt;     {&lt;br /&gt;      temp=a[i];&lt;br /&gt;      a[i]=a[j];&lt;br /&gt;      a[j]=temp;&lt;br /&gt;     }&lt;br /&gt;   }&lt;br /&gt;  }&lt;br /&gt;  printf(&quot;After sorting \n&quot;);&lt;br /&gt;  for(i=0;i&amp;lt;n;i++)&lt;br /&gt;  {&lt;br /&gt;    printf(&quot;%d &quot;,a[i]);&lt;br /&gt;  }&lt;br /&gt;}&lt;/blockquote&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.programsway.com/feeds/532799138502643108/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.programsway.com/2014/01/arrays-in-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6893346382604416070/posts/default/532799138502643108'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6893346382604416070/posts/default/532799138502643108'/><link rel='alternate' type='text/html' href='http://www.programsway.com/2014/01/arrays-in-c.html' title='ARRAYS IN C'/><author><name>Wyes Karny</name><uri>https://plus.google.com/110965746277342011781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-b---zWeiKtw/AAAAAAAAAAI/AAAAAAAAA3Y/IEVnupjQoh8/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6893346382604416070.post-1972656946320685009</id><published>2014-01-05T06:27:00.000-08:00</published><updated>2014-01-05T07:37:11.365-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Example"/><title type='text'>Example of checking palindrome and 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 class=&quot;MsoNormal&quot;&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;Here in this post we represent two basic C programming examples. Those example are only for the beginners. &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpFirst&quot; style=&quot;margin-left: 72.75pt; mso-add-space: auto; mso-list: l1 level1 lfo2; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Wingdings; mso-bidi-font-family: Wingdings; mso-fareast-font-family: Wingdings;&quot;&gt;v&lt;span style=&quot;font-family: &#39;Times New Roman&#39;; font-size: 7pt;&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot;&gt;Check whether a number is &lt;b&gt;palindrome&lt;/b&gt; or not through C program.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpLast&quot; style=&quot;margin-left: 72.75pt; mso-add-space: auto; mso-list: l1 level1 lfo2; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Wingdings; mso-bidi-font-family: Wingdings; mso-fareast-font-family: Wingdings;&quot;&gt;v&lt;span style=&quot;font-family: &#39;Times New Roman&#39;; font-size: 7pt;&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot;&gt;Check whether a number is &lt;b&gt;prime&lt;/b&gt; or not through C program.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;Now the answers are given below:&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot;&gt;Answer of no 1:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;A number is said to be palindrome if the reverse of that number is same as the original number. Coding is given below…&lt;/span&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;/* C program to check whether a number is palindrome or not */&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;#include&amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;#include&amp;lt;stdlib.h&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;int main()&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp; int n,t,rev=0;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp; printf(&quot;Give the value of of the number\n&quot;);&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp; scanf(&quot;%d&quot;,&amp;amp;n);&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp; t=n;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp; while(t!=0)&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp; {&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rev=rev*10;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rev=rev+t%10;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp; t=t/10;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;}&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;if(rev!=n)&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;printf(&quot;the entered number is not a palindrome\n&quot;);&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;else&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;printf(&quot;the entered number is palindrome number\n\n&quot;);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;b&gt;&lt;u&gt;&lt;span lang=&quot;EN-US&quot;&gt;Answer of no 2: &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/u&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;A number is said to be prime if that number is only divisible by 1 and the number itself. Coding is given below… &lt;/span&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;br /&gt;&lt;br /&gt;/* C program to check whether a number is prime or not*/&lt;br /&gt;&lt;br /&gt;#include&amp;lt;stdio.h&amp;gt;&lt;br /&gt; int main()&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt; int a,c=0,i,num;&lt;br /&gt;&lt;br /&gt; printf(&quot;Give the value of num\n&quot;);&lt;br /&gt;&lt;br /&gt; scanf(&quot;%d&quot;,&amp;amp;num);&lt;br /&gt;&lt;br /&gt; for(i=1;i&amp;lt;=num;i++)&lt;br /&gt;&lt;br /&gt; {&lt;br /&gt;&lt;br /&gt; a=num%i;&lt;br /&gt;&lt;br /&gt; if(a==0)&lt;br /&gt;&lt;br /&gt; {&lt;br /&gt;&lt;br /&gt; c=c+1;&lt;br /&gt;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; if(c==2)&lt;br /&gt;&lt;br /&gt; printf(&quot;num is prime number&quot;);&lt;br /&gt;&lt;br /&gt; else&lt;br /&gt;&lt;br /&gt; printf(&quot;num is not a prime number&quot;);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;}&lt;/blockquote&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.programsway.com/feeds/1972656946320685009/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.programsway.com/2014/01/example-of-checking-palindrome-and.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6893346382604416070/posts/default/1972656946320685009'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6893346382604416070/posts/default/1972656946320685009'/><link rel='alternate' type='text/html' href='http://www.programsway.com/2014/01/example-of-checking-palindrome-and.html' title='Example of checking palindrome and prime number'/><author><name>Wyes Karny</name><uri>https://plus.google.com/110965746277342011781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-b---zWeiKtw/AAAAAAAAAAI/AAAAAAAAA3Y/IEVnupjQoh8/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6893346382604416070.post-5586688757612667410</id><published>2013-10-03T23:16:00.000-07:00</published><updated>2013-10-03T23:16:01.061-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Algorithm"/><category scheme="http://www.blogger.com/atom/ns#" term="Insertion Sort"/><category scheme="http://www.blogger.com/atom/ns#" term="Sorting"/><category scheme="http://www.blogger.com/atom/ns#" term="Time Complexity"/><title type='text'>Algorithm of Insertion Sort</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;MsoNoSpacing&quot;&gt;&lt;b&gt;Written by Kousik :&amp;nbsp;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;This is another efficient way of solving a problem related with sorting. This algorithm works as the way people play cards. We present our procedure for insertion sort by the name INSERTION. This function takes an array of n element as input which is to be sorted. This algorithm sorts given n elements by inserting them into their right position.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;Procedure INSERTION&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp; For i=1 to n-1 do&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp; Insert(i);&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;} &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;Insert(i)/* assumes a[0], a[1],…,a[i-1] are sorted*/&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;{&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Insert a[i] in appropriate position so that a[0],a[1],…a[i-1],a[i] become sorted*/&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;Time complexity of this algorithm: &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;Look carefully in the algorithm you will see that the algorithm works for each element in the array by keeping a particular element into its right position. So the time complexity will be&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; T(n) = &lt;/span&gt;&lt;!--[if gte msEquation 12]&gt;&lt;m:oMath&gt;&lt;m:nary&gt;&lt;m:naryPr&gt;&lt;m:chr m:val=&quot;∑&quot;/&gt;&lt;m:grow     m:val=&quot;on&quot;/&gt;&lt;span style=&#39;font-family:&quot;Cambria Math&quot;,&quot;serif&quot;;mso-ascii-font-family:    &quot;Cambria Math&quot;;mso-hansi-font-family:&quot;Cambria Math&quot;&#39;&gt;&lt;m:ctrlPr&gt;&lt;/m:ctrlPr&gt;&lt;/span&gt;&lt;/m:naryPr&gt;&lt;m:sub&gt;&lt;i    style=&#39;mso-bidi-font-style:normal&#39;&gt;&lt;span lang=EN-US style=&#39;font-family:&quot;Cambria Math&quot;,&quot;serif&quot;;    mso-fareast-font-family:&quot;Cambria Math&quot;;mso-bidi-font-family:&quot;Cambria Math&quot;&#39;&gt;&lt;m:r&gt;i&lt;/m:r&gt;&lt;m:r&gt;=1&lt;/m:r&gt;&lt;/span&gt;&lt;/i&gt;&lt;/m:sub&gt;&lt;m:sup&gt;&lt;i    style=&#39;mso-bidi-font-style:normal&#39;&gt;&lt;span lang=EN-US style=&#39;font-family:&quot;Cambria Math&quot;,&quot;serif&quot;;    mso-fareast-font-family:&quot;Cambria Math&quot;;mso-bidi-font-family:&quot;Cambria Math&quot;&#39;&gt;&lt;m:r&gt;n&lt;/m:r&gt;&lt;/span&gt;&lt;/i&gt;&lt;/m:sup&gt;&lt;m:e&gt;&lt;span    lang=EN-US style=&#39;font-family:&quot;Cambria Math&quot;,&quot;serif&quot;&#39;&gt;&lt;m:r&gt;&lt;m:rPr&gt;&lt;m:scr       m:val=&quot;roman&quot;/&gt;&lt;m:sty m:val=&quot;p&quot;/&gt;&lt;/m:rPr&gt;(i)&lt;/m:r&gt;&lt;/span&gt;&lt;/m:e&gt;&lt;/m:nary&gt;&lt;/m:oMath&gt;&lt;![endif]--&gt;&lt;!--[if !msEquation]--&gt;&lt;span style=&quot;font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 115%; mso-ansi-language: EN-IN; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-language: AR-SA; mso-bidi-theme-font: minor-bidi; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-fareast-theme-font: minor-fareast; mso-hansi-theme-font: minor-latin; mso-text-raise: -5.5pt; position: relative; top: 5.5pt;&quot;&gt;&lt;v:shapetype coordsize=&quot;21600,21600&quot; filled=&quot;f&quot; id=&quot;_x0000_t75&quot; o:preferrelative=&quot;t&quot; o:spt=&quot;75&quot; path=&quot;m@4@5l@4@11@9@11@9@5xe&quot; stroked=&quot;f&quot;&gt; &lt;v:stroke joinstyle=&quot;miter&quot;&gt; &lt;v:formulas&gt;  &lt;v:f eqn=&quot;if lineDrawn pixelLineWidth 0&quot;&gt;  &lt;v:f eqn=&quot;sum @0 1 0&quot;&gt;  &lt;v:f eqn=&quot;sum 0 0 @1&quot;&gt;  &lt;v:f eqn=&quot;prod @2 1 2&quot;&gt;  &lt;v:f eqn=&quot;prod @3 21600 pixelWidth&quot;&gt;  &lt;v:f eqn=&quot;prod @3 21600 pixelHeight&quot;&gt;  &lt;v:f eqn=&quot;sum @0 0 1&quot;&gt;  &lt;v:f eqn=&quot;prod @6 1 2&quot;&gt;  &lt;v:f eqn=&quot;prod @7 21600 pixelWidth&quot;&gt;  &lt;v:f eqn=&quot;sum @8 21600 0&quot;&gt;  &lt;v:f eqn=&quot;prod @7 21600 pixelHeight&quot;&gt;  &lt;v:f eqn=&quot;sum @10 21600 0&quot;&gt; &lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:formulas&gt; &lt;v:path gradientshapeok=&quot;t&quot; o:connecttype=&quot;rect&quot; o:extrusionok=&quot;f&quot;&gt; &lt;o:lock aspectratio=&quot;t&quot; v:ext=&quot;edit&quot;&gt;&lt;/o:lock&gt;&lt;/v:path&gt;&lt;/v:stroke&gt;&lt;/v:shapetype&gt;&lt;v:shape id=&quot;_x0000_i1025&quot; style=&quot;height: 17.25pt; width: 38.25pt;&quot; type=&quot;#_x0000_t75&quot;&gt; &lt;v:imagedata chromakey=&quot;white&quot; o:title=&quot;&quot; src=&quot;file:///C:\Users\WYES\AppData\Local\Temp\msohtmlclip1\01\clip_image001.png&quot;&gt;&lt;/v:imagedata&gt;&lt;/v:shape&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; =n(n+1)/2&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;=n&lt;sup&gt;2&lt;/sup&gt;/2=O(n&lt;sup&gt;2&lt;/sup&gt;)&lt;sub&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/sub&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;So it is efficient algorithm because it takes the polynomial time complexity for executing.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;Now we have to write the C code for this algorithm&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;/* A c program for insertion sort*/&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;#include&amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;#include&amp;lt;stdlib.h&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;int *a,n;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;void insert();&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;int main()&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp; int i;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp; printf(&quot;Enter the total number of elements: &quot;);&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp; scanf(&quot;%d&quot;,&amp;amp;n);&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp; a=(int *)calloc(n,sizeof(int));&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp; printf(&quot;Enter the values: &quot;);&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp; for(i=0;i&amp;lt;n;i++)&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp; scanf(&quot;%d&quot;,&amp;amp;a[i]);&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp; insert();&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp; printf(&quot;The sorted array: &quot;);&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp; for(i=0;i&amp;lt;n;i++)&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp; printf(&quot;%d &quot;,a[i]);&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp; return 0;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;void insert(void)&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; int i,j,temp;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for(i=1;i&amp;lt;n;i++)&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; temp=a[i];&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; j=i-1;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; while((temp&amp;lt;a[j])&amp;amp;&amp;amp;(j&amp;gt;=0))&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; a[j+1]=a[j];&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; j=j-1;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; a[j+1]=temp;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.programsway.com/feeds/5586688757612667410/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.programsway.com/2013/10/algorithm-of-insertion-sort.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6893346382604416070/posts/default/5586688757612667410'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6893346382604416070/posts/default/5586688757612667410'/><link rel='alternate' type='text/html' href='http://www.programsway.com/2013/10/algorithm-of-insertion-sort.html' title='Algorithm of Insertion Sort'/><author><name>Wyes Karny</name><uri>https://plus.google.com/110965746277342011781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-b---zWeiKtw/AAAAAAAAAAI/AAAAAAAAA3Y/IEVnupjQoh8/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6893346382604416070.post-8899083320926453027</id><published>2013-10-03T23:10:00.000-07:00</published><updated>2013-10-03T23:18:12.954-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Algorithm"/><category scheme="http://www.blogger.com/atom/ns#" term="Sorting"/><title type='text'>Algorithm of Quicksort </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;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;Written by Kousik :&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;QUICKSORT(S)&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;{&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot; style=&quot;margin-left: 36.0pt; mso-list: l2 level1 lfo1; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot;&gt;1.&lt;span style=&quot;font-size: 7pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot;&gt;If ||S||&amp;lt;=1 return;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot; style=&quot;margin-left: 36.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;else {&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;2.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Select a first element e as pivot from s.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3. &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Compare elements of s with e to partition S into subsets S&lt;sub&gt;1&lt;/sub&gt;, S&lt;sub&gt;2&lt;/sub&gt;, S&lt;sub&gt;3&amp;nbsp; &lt;/sub&gt;such that&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Elements of S&lt;sub&gt;1&lt;/sub&gt; are less than e.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Elements of S&lt;sub&gt;2 &lt;/sub&gt;are equal to e.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Elements of S&lt;sub&gt;3 &lt;/sub&gt;are greater than e.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4. return (QUICKSORT(S&lt;sub&gt;1&lt;/sub&gt;), followed by S&lt;sub&gt;2&lt;/sub&gt;, QUICKSORT(S&lt;sub&gt;3&lt;/sub&gt;)) ;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;}&lt;sub&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/sub&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;Implementation of step 2 [Partitioning] &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot; style=&quot;margin-left: 36.0pt; mso-list: l3 level1 lfo2; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot;&gt;1)&lt;span style=&quot;font-size: 7pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot;&gt;Select the very first element of S as pivot.(Simplest implementation)&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot; style=&quot;margin-left: 36.0pt; mso-list: l3 level1 lfo2; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot;&gt;2)&lt;span style=&quot;font-size: 7pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot;&gt;Select pivot from S at random.(Randomized implementation)&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;Analysis of Time complexity of this algorithm:&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;Let T(n) be the time complexity of this algorithm.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot; style=&quot;margin-left: 54.0pt; mso-list: l1 level1 lfo3; text-indent: -36.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot;&gt;i)&lt;span style=&quot;font-size: 7pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;u&gt;&lt;span lang=&quot;EN-US&quot;&gt;Worst Case&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/u&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot; style=&quot;margin-left: 54.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;T(n) = T(0) + T(n-1) + n -1&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot; style=&quot;margin-left: 54.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = 1+ T(n-1) + n -1&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot; style=&quot;margin-left: 54.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = T(n-1)+n&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot; style=&quot;margin-left: 54.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = n(n+1)/2 = &lt;b&gt;O(n&lt;sup&gt;2&lt;/sup&gt;)&lt;/b&gt; &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot; style=&quot;margin-left: 54.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;This is a polynomial in time complexity. So this is a nice algorithm for solving a sorting problem. But we use this algorithm in a better way such that the time complexity of this algorithm reduced to O(nlogn).&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot; style=&quot;margin-left: 54.0pt; mso-list: l1 level1 lfo3; text-indent: -36.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot;&gt;ii)&lt;span style=&quot;font-size: 7pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;u&gt;&lt;span lang=&quot;EN-US&quot;&gt;Best Case:&lt;/span&gt;&lt;/u&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot; style=&quot;margin-left: 54.0pt;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;table border=&quot;1&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;MsoTableGrid&quot; style=&quot;border-collapse: collapse; border: none; margin-left: 54.0pt; mso-border-alt: solid black .5pt; mso-border-themecolor: text1; mso-padding-alt: 0cm 5.4pt 0cm 5.4pt; mso-yfti-tbllook: 1184;&quot;&gt; &lt;tbody&gt;&lt;tr&gt;  &lt;td style=&quot;border: solid black 1.0pt; mso-border-alt: solid black .5pt; mso-border-themecolor: text1; mso-border-themecolor: text1; padding: 0cm 5.4pt 0cm 5.4pt; width: 239.4pt;&quot; valign=&quot;top&quot; width=&quot;319&quot;&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;- n/2 elements&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;td style=&quot;border-left: none; border: solid black 1.0pt; mso-border-alt: solid black .5pt; mso-border-left-alt: solid black .5pt; mso-border-left-themecolor: text1; mso-border-themecolor: text1; mso-border-themecolor: text1; padding: 0cm 5.4pt 0cm 5.4pt; width: 239.4pt;&quot; valign=&quot;top&quot; width=&quot;319&quot;&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -&amp;gt;n/2   elements&lt;/span&gt;&lt;/div&gt;&lt;/td&gt; &lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div class=&quot;MsoNoSpacing&quot; style=&quot;margin-left: 54.0pt;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot; style=&quot;margin-left: 54.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;Time complexity will be&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot; style=&quot;margin-left: 54.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; T(n)=2T(n/2)+n&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot; style=&quot;margin-left: 54.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; T(n)=&lt;b&gt;O(nlogn)&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot; style=&quot;margin-left: 54.0pt; mso-list: l1 level1 lfo3; text-indent: -36.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot;&gt;iii)&lt;span style=&quot;font-size: 7pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;u&gt;&lt;span lang=&quot;EN-US&quot;&gt;Average case:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/u&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [Assumption: all elements of S are eq&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 10.0pt;&quot;&gt;ual probable to be the pivot in &lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;QUICKSORT(S)]&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot; style=&quot;margin-left: 54.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;Let ith smallest element appear as pivot then &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot; style=&quot;margin-left: 54.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;T(n)=n -1+T(i-1)+T(n-i)&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot; style=&quot;margin-left: 54.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; =cn+T(i-1)+T(n-i)&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot; style=&quot;margin-left: 54.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;Total time require by randomized quick sort algorithm is T(n).&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot; style=&quot;margin-left: 18.0pt; text-indent: 36.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;T(n)=(1/n)&lt;/span&gt;&lt;!--[if gte msEquation 12]&gt;&lt;m:oMath&gt;&lt;m:nary&gt;&lt;m:naryPr&gt;&lt;m:chr     m:val=&quot;∑&quot;/&gt;&lt;m:grow m:val=&quot;on&quot;/&gt;&lt;span style=&#39;font-family:&quot;Cambria Math&quot;,&quot;serif&quot;;    mso-ascii-font-family:&quot;Cambria Math&quot;;mso-hansi-font-family:&quot;Cambria Math&quot;&#39;&gt;&lt;m:ctrlPr&gt;&lt;/m:ctrlPr&gt;&lt;/span&gt;&lt;/m:naryPr&gt;&lt;m:sub&gt;&lt;i    style=&#39;mso-bidi-font-style:normal&#39;&gt;&lt;span lang=EN-US style=&#39;font-family:&quot;Cambria Math&quot;,&quot;serif&quot;;    mso-fareast-font-family:&quot;Cambria Math&quot;;mso-bidi-font-family:&quot;Cambria Math&quot;&#39;&gt;&lt;m:r&gt;i&lt;/m:r&gt;&lt;m:r&gt;=1&lt;/m:r&gt;&lt;/span&gt;&lt;/i&gt;&lt;/m:sub&gt;&lt;m:sup&gt;&lt;i    style=&#39;mso-bidi-font-style:normal&#39;&gt;&lt;span lang=EN-US style=&#39;font-family:&quot;Cambria Math&quot;,&quot;serif&quot;;    mso-fareast-font-family:&quot;Cambria Math&quot;;mso-bidi-font-family:&quot;Cambria Math&quot;&#39;&gt;&lt;m:r&gt;n&lt;/m:r&gt;&lt;/span&gt;&lt;/i&gt;&lt;/m:sup&gt;&lt;m:e&gt;&lt;m:d&gt;&lt;m:dPr&gt;&lt;m:begChr       m:val=&quot;[&quot;/&gt;&lt;m:endChr m:val=&quot;]&quot;/&gt;&lt;span style=&#39;font-family:&quot;Cambria Math&quot;,&quot;serif&quot;;      mso-ascii-font-family:&quot;Cambria Math&quot;;mso-hansi-font-family:&quot;Cambria Math&quot;&#39;&gt;&lt;m:ctrlPr&gt;&lt;/m:ctrlPr&gt;&lt;/span&gt;&lt;/m:dPr&gt;&lt;m:e&gt;&lt;span      lang=EN-US style=&#39;font-family:&quot;Cambria Math&quot;,&quot;serif&quot;&#39;&gt;&lt;m:r&gt;&lt;m:rPr&gt;&lt;m:scr         m:val=&quot;roman&quot;/&gt;&lt;m:sty m:val=&quot;p&quot;/&gt;&lt;/m:rPr&gt;cn+T&lt;/m:r&gt;&lt;/span&gt;&lt;m:d&gt;&lt;m:dPr&gt;&lt;span        style=&#39;font-family:&quot;Cambria Math&quot;,&quot;serif&quot;;mso-ascii-font-family:&quot;Cambria Math&quot;;        mso-hansi-font-family:&quot;Cambria Math&quot;&#39;&gt;&lt;m:ctrlPr&gt;&lt;/m:ctrlPr&gt;&lt;/span&gt;&lt;/m:dPr&gt;&lt;m:e&gt;&lt;span        lang=EN-US style=&#39;font-family:&quot;Cambria Math&quot;,&quot;serif&quot;&#39;&gt;&lt;m:r&gt;&lt;m:rPr&gt;&lt;m:scr           m:val=&quot;roman&quot;/&gt;&lt;m:sty m:val=&quot;p&quot;/&gt;&lt;/m:rPr&gt;i-1&lt;/m:r&gt;&lt;/span&gt;&lt;/m:e&gt;&lt;/m:d&gt;&lt;span      lang=EN-US style=&#39;font-family:&quot;Cambria Math&quot;,&quot;serif&quot;&#39;&gt;&lt;m:r&gt;&lt;m:rPr&gt;&lt;m:scr         m:val=&quot;roman&quot;/&gt;&lt;m:sty m:val=&quot;p&quot;/&gt;&lt;/m:rPr&gt;+T&lt;/m:r&gt;&lt;/span&gt;&lt;m:d&gt;&lt;m:dPr&gt;&lt;span        style=&#39;font-family:&quot;Cambria Math&quot;,&quot;serif&quot;;mso-ascii-font-family:&quot;Cambria Math&quot;;        mso-hansi-font-family:&quot;Cambria Math&quot;&#39;&gt;&lt;m:ctrlPr&gt;&lt;/m:ctrlPr&gt;&lt;/span&gt;&lt;/m:dPr&gt;&lt;m:e&gt;&lt;span        lang=EN-US style=&#39;font-family:&quot;Cambria Math&quot;,&quot;serif&quot;&#39;&gt;&lt;m:r&gt;&lt;m:rPr&gt;&lt;m:scr           m:val=&quot;roman&quot;/&gt;&lt;m:sty m:val=&quot;p&quot;/&gt;&lt;/m:rPr&gt;n-i&lt;/m:r&gt;&lt;/span&gt;&lt;/m:e&gt;&lt;/m:d&gt;&lt;/m:e&gt;&lt;/m:d&gt;&lt;/m:e&gt;&lt;/m:nary&gt;&lt;/m:oMath&gt;&lt;![endif]--&gt;&lt;!--[if !msEquation]--&gt;&lt;span style=&quot;font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 115%; mso-ansi-language: EN-IN; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-language: AR-SA; mso-bidi-theme-font: minor-bidi; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-fareast-theme-font: minor-fareast; mso-hansi-theme-font: minor-latin; mso-text-raise: -3.0pt; position: relative; top: 3.0pt;&quot;&gt;&lt;v:shapetype coordsize=&quot;21600,21600&quot; filled=&quot;f&quot; id=&quot;_x0000_t75&quot; o:preferrelative=&quot;t&quot; o:spt=&quot;75&quot; path=&quot;m@4@5l@4@11@9@11@9@5xe&quot; stroked=&quot;f&quot;&gt; &lt;v:stroke joinstyle=&quot;miter&quot;&gt; &lt;v:formulas&gt;  &lt;v:f eqn=&quot;if lineDrawn pixelLineWidth 0&quot;&gt;  &lt;v:f eqn=&quot;sum @0 1 0&quot;&gt;  &lt;v:f eqn=&quot;sum 0 0 @1&quot;&gt;  &lt;v:f eqn=&quot;prod @2 1 2&quot;&gt;  &lt;v:f eqn=&quot;prod @3 21600 pixelWidth&quot;&gt;  &lt;v:f eqn=&quot;prod @3 21600 pixelHeight&quot;&gt;  &lt;v:f eqn=&quot;sum @0 0 1&quot;&gt;  &lt;v:f eqn=&quot;prod @6 1 2&quot;&gt;  &lt;v:f eqn=&quot;prod @7 21600 pixelWidth&quot;&gt;  &lt;v:f eqn=&quot;sum @8 21600 0&quot;&gt;  &lt;v:f eqn=&quot;prod @7 21600 pixelHeight&quot;&gt;  &lt;v:f eqn=&quot;sum @10 21600 0&quot;&gt; &lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:formulas&gt; &lt;v:path gradientshapeok=&quot;t&quot; o:connecttype=&quot;rect&quot; o:extrusionok=&quot;f&quot;&gt; &lt;o:lock aspectratio=&quot;t&quot; v:ext=&quot;edit&quot;&gt;&lt;/o:lock&gt;&lt;/v:path&gt;&lt;/v:stroke&gt;&lt;/v:shapetype&gt;&lt;v:shape id=&quot;_x0000_i1025&quot; style=&quot;height: 13.5pt; width: 141.75pt;&quot; type=&quot;#_x0000_t75&quot;&gt; &lt;v:imagedata chromakey=&quot;white&quot; o:title=&quot;&quot; src=&quot;file:///C:\Users\WYES\AppData\Local\Temp\msohtmlclip1\01\clip_image001.png&quot;&gt;&lt;/v:imagedata&gt;&lt;/v:shape&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot; style=&quot;margin-left: 54.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;Assume T(0)=T(1)=b&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot; style=&quot;margin-left: 54.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;Then T(n)=(1/n)&lt;/span&gt;&lt;!--[if gte msEquation 12]&gt;&lt;m:oMath&gt;&lt;m:nary&gt;&lt;m:naryPr&gt;&lt;m:chr     m:val=&quot;∑&quot;/&gt;&lt;m:grow m:val=&quot;on&quot;/&gt;&lt;span style=&#39;font-family:&quot;Cambria Math&quot;,&quot;serif&quot;;    mso-ascii-font-family:&quot;Cambria Math&quot;;mso-hansi-font-family:&quot;Cambria Math&quot;&#39;&gt;&lt;m:ctrlPr&gt;&lt;/m:ctrlPr&gt;&lt;/span&gt;&lt;/m:naryPr&gt;&lt;m:sub&gt;&lt;i    style=&#39;mso-bidi-font-style:normal&#39;&gt;&lt;span lang=EN-US style=&#39;font-family:&quot;Cambria Math&quot;,&quot;serif&quot;;    mso-fareast-font-family:&quot;Cambria Math&quot;;mso-bidi-font-family:&quot;Cambria Math&quot;&#39;&gt;&lt;m:r&gt;i&lt;/m:r&gt;&lt;m:r&gt;=1&lt;/m:r&gt;&lt;/span&gt;&lt;/i&gt;&lt;/m:sub&gt;&lt;m:sup&gt;&lt;i    style=&#39;mso-bidi-font-style:normal&#39;&gt;&lt;span lang=EN-US style=&#39;font-family:&quot;Cambria Math&quot;,&quot;serif&quot;;    mso-fareast-font-family:&quot;Cambria Math&quot;;mso-bidi-font-family:&quot;Cambria Math&quot;&#39;&gt;&lt;m:r&gt;n&lt;/m:r&gt;&lt;/span&gt;&lt;/i&gt;&lt;/m:sup&gt;&lt;m:e&gt;&lt;m:d&gt;&lt;m:dPr&gt;&lt;m:begChr       m:val=&quot;[&quot;/&gt;&lt;m:endChr m:val=&quot;]&quot;/&gt;&lt;span style=&#39;font-family:&quot;Cambria Math&quot;,&quot;serif&quot;;      mso-ascii-font-family:&quot;Cambria Math&quot;;mso-hansi-font-family:&quot;Cambria Math&quot;&#39;&gt;&lt;m:ctrlPr&gt;&lt;/m:ctrlPr&gt;&lt;/span&gt;&lt;/m:dPr&gt;&lt;m:e&gt;&lt;span      lang=EN-US style=&#39;font-family:&quot;Cambria Math&quot;,&quot;serif&quot;&#39;&gt;&lt;m:r&gt;&lt;m:rPr&gt;&lt;m:scr         m:val=&quot;roman&quot;/&gt;&lt;m:sty m:val=&quot;p&quot;/&gt;&lt;/m:rPr&gt;cn+T&lt;/m:r&gt;&lt;/span&gt;&lt;m:d&gt;&lt;m:dPr&gt;&lt;span        style=&#39;font-family:&quot;Cambria Math&quot;,&quot;serif&quot;;mso-ascii-font-family:&quot;Cambria Math&quot;;        mso-hansi-font-family:&quot;Cambria Math&quot;&#39;&gt;&lt;m:ctrlPr&gt;&lt;/m:ctrlPr&gt;&lt;/span&gt;&lt;/m:dPr&gt;&lt;m:e&gt;&lt;span        lang=EN-US style=&#39;font-family:&quot;Cambria Math&quot;,&quot;serif&quot;&#39;&gt;&lt;m:r&gt;&lt;m:rPr&gt;&lt;m:scr           m:val=&quot;roman&quot;/&gt;&lt;m:sty m:val=&quot;p&quot;/&gt;&lt;/m:rPr&gt;i-1&lt;/m:r&gt;&lt;/span&gt;&lt;/m:e&gt;&lt;/m:d&gt;&lt;span      lang=EN-US style=&#39;font-family:&quot;Cambria Math&quot;,&quot;serif&quot;&#39;&gt;&lt;m:r&gt;&lt;m:rPr&gt;&lt;m:scr         m:val=&quot;roman&quot;/&gt;&lt;m:sty m:val=&quot;p&quot;/&gt;&lt;/m:rPr&gt;+T&lt;/m:r&gt;&lt;/span&gt;&lt;m:d&gt;&lt;m:dPr&gt;&lt;span        style=&#39;font-family:&quot;Cambria Math&quot;,&quot;serif&quot;;mso-ascii-font-family:&quot;Cambria Math&quot;;        mso-hansi-font-family:&quot;Cambria Math&quot;&#39;&gt;&lt;m:ctrlPr&gt;&lt;/m:ctrlPr&gt;&lt;/span&gt;&lt;/m:dPr&gt;&lt;m:e&gt;&lt;span        lang=EN-US style=&#39;font-family:&quot;Cambria Math&quot;,&quot;serif&quot;&#39;&gt;&lt;m:r&gt;&lt;m:rPr&gt;&lt;m:scr           m:val=&quot;roman&quot;/&gt;&lt;m:sty m:val=&quot;p&quot;/&gt;&lt;/m:rPr&gt;n-i&lt;/m:r&gt;&lt;/span&gt;&lt;/m:e&gt;&lt;/m:d&gt;&lt;/m:e&gt;&lt;/m:d&gt;&lt;/m:e&gt;&lt;/m:nary&gt;&lt;/m:oMath&gt;&lt;![endif]--&gt;&lt;!--[if !msEquation]--&gt;&lt;span style=&quot;font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 115%; mso-ansi-language: EN-IN; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-language: AR-SA; mso-bidi-theme-font: minor-bidi; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-fareast-theme-font: minor-fareast; mso-hansi-theme-font: minor-latin; mso-text-raise: -3.0pt; position: relative; top: 3.0pt;&quot;&gt;&lt;v:shape id=&quot;_x0000_i1025&quot; style=&quot;height: 13.5pt; width: 141.75pt;&quot; type=&quot;#_x0000_t75&quot;&gt; &lt;v:imagedata chromakey=&quot;white&quot; o:title=&quot;&quot; src=&quot;file:///C:\Users\WYES\AppData\Local\Temp\msohtmlclip1\01\clip_image001.png&quot;&gt;&lt;/v:imagedata&gt;&lt;/v:shape&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot; style=&quot;margin-left: 54.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; T(n&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;)=(1/n)&lt;/span&gt;&lt;!--[if gte msEquation 12]&gt;&lt;m:oMath&gt;&lt;m:nary&gt;&lt;m:naryPr&gt;&lt;m:chr     m:val=&quot;∑&quot;/&gt;&lt;m:grow m:val=&quot;on&quot;/&gt;&lt;span style=&#39;font-family:&quot;Cambria Math&quot;,&quot;serif&quot;;    mso-ascii-font-family:&quot;Cambria Math&quot;;mso-hansi-font-family:&quot;Cambria Math&quot;&#39;&gt;&lt;m:ctrlPr&gt;&lt;/m:ctrlPr&gt;&lt;/span&gt;&lt;/m:naryPr&gt;&lt;m:sub&gt;&lt;i    style=&#39;mso-bidi-font-style:normal&#39;&gt;&lt;span lang=EN-US style=&#39;font-family:&quot;Cambria Math&quot;,&quot;serif&quot;;    mso-fareast-font-family:&quot;Cambria Math&quot;;mso-bidi-font-family:&quot;Cambria Math&quot;&#39;&gt;&lt;m:r&gt;i&lt;/m:r&gt;&lt;m:r&gt;=1&lt;/m:r&gt;&lt;/span&gt;&lt;/i&gt;&lt;/m:sub&gt;&lt;m:sup&gt;&lt;i    style=&#39;mso-bidi-font-style:normal&#39;&gt;&lt;span lang=EN-US style=&#39;font-family:&quot;Cambria Math&quot;,&quot;serif&quot;;    mso-fareast-font-family:&quot;Cambria Math&quot;;mso-bidi-font-family:&quot;Cambria Math&quot;&#39;&gt;&lt;m:r&gt;n&lt;/m:r&gt;&lt;/span&gt;&lt;/i&gt;&lt;/m:sup&gt;&lt;m:e&gt;&lt;m:d&gt;&lt;m:dPr&gt;&lt;m:begChr       m:val=&quot;[&quot;/&gt;&lt;m:endChr m:val=&quot;]&quot;/&gt;&lt;span style=&#39;font-family:&quot;Cambria Math&quot;,&quot;serif&quot;;      mso-ascii-font-family:&quot;Cambria Math&quot;;mso-hansi-font-family:&quot;Cambria Math&quot;&#39;&gt;&lt;m:ctrlPr&gt;&lt;/m:ctrlPr&gt;&lt;/span&gt;&lt;/m:dPr&gt;&lt;m:e&gt;&lt;span      lang=EN-US style=&#39;font-family:&quot;Cambria Math&quot;,&quot;serif&quot;&#39;&gt;&lt;m:r&gt;&lt;m:rPr&gt;&lt;m:scr         m:val=&quot;roman&quot;/&gt;&lt;m:sty m:val=&quot;p&quot;/&gt;&lt;/m:rPr&gt;cn+2T(i)&lt;/m:r&gt;&lt;/span&gt;&lt;/m:e&gt;&lt;/m:d&gt;&lt;/m:e&gt;&lt;/m:nary&gt;&lt;/m:oMath&gt;&lt;![endif]--&gt;&lt;!--[if !msEquation]--&gt;&lt;span style=&quot;font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 115%; mso-ansi-language: EN-IN; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-language: AR-SA; mso-bidi-theme-font: minor-bidi; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-fareast-theme-font: minor-fareast; mso-hansi-theme-font: minor-latin; mso-text-raise: -5.5pt; position: relative; top: 5.5pt;&quot;&gt;&lt;v:shape id=&quot;_x0000_i1025&quot; style=&quot;height: 17.25pt; width: 82.5pt;&quot; type=&quot;#_x0000_t75&quot;&gt; &lt;v:imagedata chromakey=&quot;white&quot; o:title=&quot;&quot; src=&quot;file:///C:\Users\WYES\AppData\Local\Temp\msohtmlclip1\01\clip_image002.png&quot;&gt;&lt;/v:imagedata&gt;&lt;/v:shape&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot; style=&quot;margin-left: 54.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = cn+(1/n) &lt;/span&gt;&lt;!--[if gte msEquation 12]&gt;&lt;m:oMath&gt;&lt;m:nary&gt;&lt;m:naryPr&gt;&lt;m:chr     m:val=&quot;∑&quot;/&gt;&lt;m:grow m:val=&quot;on&quot;/&gt;&lt;span style=&#39;font-family:&quot;Cambria Math&quot;,&quot;serif&quot;;    mso-ascii-font-family:&quot;Cambria Math&quot;;mso-hansi-font-family:&quot;Cambria Math&quot;&#39;&gt;&lt;m:ctrlPr&gt;&lt;/m:ctrlPr&gt;&lt;/span&gt;&lt;/m:naryPr&gt;&lt;m:sub&gt;&lt;i    style=&#39;mso-bidi-font-style:normal&#39;&gt;&lt;span lang=EN-US style=&#39;font-family:&quot;Cambria Math&quot;,&quot;serif&quot;;    mso-fareast-font-family:&quot;Cambria Math&quot;;mso-bidi-font-family:&quot;Cambria Math&quot;&#39;&gt;&lt;m:r&gt;i&lt;/m:r&gt;&lt;m:r&gt;=1&lt;/m:r&gt;&lt;/span&gt;&lt;/i&gt;&lt;/m:sub&gt;&lt;m:sup&gt;&lt;i    style=&#39;mso-bidi-font-style:normal&#39;&gt;&lt;span lang=EN-US style=&#39;font-family:&quot;Cambria Math&quot;,&quot;serif&quot;;    mso-fareast-font-family:&quot;Cambria Math&quot;;mso-bidi-font-family:&quot;Cambria Math&quot;&#39;&gt;&lt;m:r&gt;n&lt;/m:r&gt;&lt;/span&gt;&lt;/i&gt;&lt;/m:sup&gt;&lt;m:e&gt;&lt;m:d&gt;&lt;m:dPr&gt;&lt;m:begChr       m:val=&quot;[&quot;/&gt;&lt;m:endChr m:val=&quot;]&quot;/&gt;&lt;span style=&#39;font-family:&quot;Cambria Math&quot;,&quot;serif&quot;;      mso-ascii-font-family:&quot;Cambria Math&quot;;mso-hansi-font-family:&quot;Cambria Math&quot;&#39;&gt;&lt;m:ctrlPr&gt;&lt;/m:ctrlPr&gt;&lt;/span&gt;&lt;/m:dPr&gt;&lt;m:e&gt;&lt;span      lang=EN-US style=&#39;font-family:&quot;Cambria Math&quot;,&quot;serif&quot;&#39;&gt;&lt;m:r&gt;&lt;m:rPr&gt;&lt;m:scr         m:val=&quot;roman&quot;/&gt;&lt;m:sty m:val=&quot;p&quot;/&gt;&lt;/m:rPr&gt;2T(i)&lt;/m:r&gt;&lt;/span&gt;&lt;/m:e&gt;&lt;/m:d&gt;&lt;/m:e&gt;&lt;/m:nary&gt;&lt;/m:oMath&gt;&lt;![endif]--&gt;&lt;!--[if !msEquation]--&gt;&lt;span style=&quot;font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 115%; mso-ansi-language: EN-IN; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-language: AR-SA; mso-bidi-theme-font: minor-bidi; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-fareast-theme-font: minor-fareast; mso-hansi-theme-font: minor-latin; mso-text-raise: -5.5pt; position: relative; top: 5.5pt;&quot;&gt;&lt;v:shape id=&quot;_x0000_i1025&quot; style=&quot;height: 17.25pt; width: 58.5pt;&quot; type=&quot;#_x0000_t75&quot;&gt; &lt;v:imagedata chromakey=&quot;white&quot; o:title=&quot;&quot; src=&quot;file:///C:\Users\WYES\AppData\Local\Temp\msohtmlclip1\01\clip_image003.png&quot;&gt;&lt;/v:imagedata&gt;&lt;/v:shape&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot; style=&quot;margin-left: 54.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; =  cn+(2/n)&lt;/span&gt;&lt;!--[if gte msEquation 12]&gt;&lt;m:oMath&gt;&lt;span  lang=EN-US style=&#39;font-family:&quot;Cambria Math&quot;,&quot;serif&quot;&#39;&gt;&lt;m:r&gt;&lt;m:rPr&gt;&lt;m:scr     m:val=&quot;roman&quot;/&gt;&lt;m:sty m:val=&quot;p&quot;/&gt;&lt;/m:rPr&gt; &lt;/m:r&gt;&lt;/span&gt;&lt;m:nary&gt;&lt;m:naryPr&gt;&lt;m:chr     m:val=&quot;∑&quot;/&gt;&lt;m:grow m:val=&quot;on&quot;/&gt;&lt;span style=&#39;font-family:&quot;Cambria Math&quot;,&quot;serif&quot;;    mso-ascii-font-family:&quot;Cambria Math&quot;;mso-hansi-font-family:&quot;Cambria Math&quot;&#39;&gt;&lt;m:ctrlPr&gt;&lt;/m:ctrlPr&gt;&lt;/span&gt;&lt;/m:naryPr&gt;&lt;m:sub&gt;&lt;i    style=&#39;mso-bidi-font-style:normal&#39;&gt;&lt;span lang=EN-US style=&#39;font-family:&quot;Cambria Math&quot;,&quot;serif&quot;;    mso-fareast-font-family:&quot;Cambria Math&quot;;mso-bidi-font-family:&quot;Cambria Math&quot;&#39;&gt;&lt;m:r&gt;i&lt;/m:r&gt;&lt;m:r&gt;=1&lt;/m:r&gt;&lt;/span&gt;&lt;/i&gt;&lt;/m:sub&gt;&lt;m:sup&gt;&lt;i    style=&#39;mso-bidi-font-style:normal&#39;&gt;&lt;span lang=EN-US style=&#39;font-family:&quot;Cambria Math&quot;,&quot;serif&quot;;    mso-fareast-font-family:&quot;Cambria Math&quot;;mso-bidi-font-family:&quot;Cambria Math&quot;&#39;&gt;&lt;m:r&gt;n&lt;/m:r&gt;&lt;/span&gt;&lt;/i&gt;&lt;/m:sup&gt;&lt;m:e&gt;&lt;m:d&gt;&lt;m:dPr&gt;&lt;m:begChr       m:val=&quot;[&quot;/&gt;&lt;m:endChr m:val=&quot;]&quot;/&gt;&lt;span style=&#39;font-family:&quot;Cambria Math&quot;,&quot;serif&quot;;      mso-ascii-font-family:&quot;Cambria Math&quot;;mso-hansi-font-family:&quot;Cambria Math&quot;&#39;&gt;&lt;m:ctrlPr&gt;&lt;/m:ctrlPr&gt;&lt;/span&gt;&lt;/m:dPr&gt;&lt;m:e&gt;&lt;span      lang=EN-US style=&#39;font-family:&quot;Cambria Math&quot;,&quot;serif&quot;&#39;&gt;&lt;m:r&gt;&lt;m:rPr&gt;&lt;m:scr         m:val=&quot;roman&quot;/&gt;&lt;m:sty m:val=&quot;p&quot;/&gt;&lt;/m:rPr&gt;T(i)&lt;/m:r&gt;&lt;/span&gt;&lt;/m:e&gt;&lt;/m:d&gt;&lt;/m:e&gt;&lt;/m:nary&gt;&lt;/m:oMath&gt;&lt;![endif]--&gt;&lt;!--[if !msEquation]--&gt;&lt;span style=&quot;font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 115%; mso-ansi-language: EN-IN; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-language: AR-SA; mso-bidi-theme-font: minor-bidi; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-fareast-theme-font: minor-fareast; mso-hansi-theme-font: minor-latin; mso-text-raise: -5.5pt; position: relative; top: 5.5pt;&quot;&gt;&lt;v:shape id=&quot;_x0000_i1025&quot; style=&quot;height: 17.25pt; width: 54.75pt;&quot; type=&quot;#_x0000_t75&quot;&gt; &lt;v:imagedata chromakey=&quot;white&quot; o:title=&quot;&quot; src=&quot;file:///C:\Users\WYES\AppData\Local\Temp\msohtmlclip1\01\clip_image004.png&quot;&gt;&lt;/v:imagedata&gt;&lt;/v:shape&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot; style=&quot;margin-left: 54.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;= &lt;b&gt;O(nlogn)&lt;/b&gt; [ for proof follow this book: Design and analysis of algorithm (aho: hofcroft: ullman)]&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;Now it is time for writing the average or randomized algorithm for quick sort.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;Same procedure will be used in here except the method of pivot element.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;QUICKSORT(S)&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;{&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot; style=&quot;margin-left: 36.0pt; mso-list: l0 level1 lfo4; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot;&gt;1.&lt;span style=&quot;font-size: 7pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot;&gt;If ||S||&amp;lt;=1 return;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot; style=&quot;margin-left: 36.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;else {&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select an element e as pivot from s in a random manner.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3. &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;compare elements of s with e to partition S into subsets S&lt;sub&gt;1&lt;/sub&gt;, S&lt;sub&gt;2&lt;/sub&gt;, S&lt;sub&gt;3&amp;nbsp; &lt;/sub&gt;such that&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Elements of S&lt;sub&gt;1&lt;/sub&gt; are less than e.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Elements of S&lt;sub&gt;2 &lt;/sub&gt;are equal to e.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Elements of S&lt;sub&gt;3 &lt;/sub&gt;are greater than e.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4. return (QUICKSORT(S&lt;sub&gt;1&lt;/sub&gt;), followed by S&lt;sub&gt;2&lt;/sub&gt;, QUICKSORT(S&lt;sub&gt;3&lt;/sub&gt;)) ;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;}&lt;sub&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/sub&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;See carefully at the line 2.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;Before the pivot was the very first element but now it would be any element of s.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;This is the big advantage of randomized quick sort algorithm.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;Now we have to write the C code for randomized quick sort algorithm.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot;&gt;/* A program for randomized quick sort*/&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;#include&amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;#include&amp;lt;stdlib.h&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;int *a,n;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;void swap(int *a1,int *a2)/* function for swapping two element*/&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;int k;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; k=*a1;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; *a1=*a2;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; *a2=k;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;int partition(int i,int j)/* function for partition the array into three sub arrays*/&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;int x,p,v;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x=a[j];&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; p=i-1;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for(v=i;v&amp;lt;=j-1;v++)&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;if(a[v]&amp;lt;=x)&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;{&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; p++;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; swap(a+p,a+v);&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;swap(&amp;amp;a[p+1],&amp;amp;a[j]); &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return(p+1);&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;int rand_partition(int i,int j)/* function to finding the random number*/&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int q;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; q=rand()%(j-i)+i;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; swap(a+q,a+j);&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return partition(i,j);&amp;nbsp;&amp;nbsp;  &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;void quicksort(int i,int j)/* function for main alogorithm QUICKSORT(S)*/&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; int b;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(i&amp;lt;j)&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; b=rand_partition(i,j);&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; quicksort(i,b-1);&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; quicksort(b+1,j);&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;void main()&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; int i;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&quot;\n Enter the number of elements in the array: &quot;);&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; scanf(&quot;%d&quot;,&amp;amp;n);&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; a=(int*)malloc(n*sizeof(int));&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&quot;\n Enter the elements in the array: &quot;);&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for(i=0;i&amp;lt;n;i++)&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; scanf(&quot;%d&quot;,a+i);&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&quot;\n The array before sorting is: &quot;);&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for(i=0;i&amp;lt;n;i++)&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&quot;%d &quot;,a[i]);&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; quicksort(0,n-1);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&quot;\n&quot;);&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&quot;\n The array after sorting is:&quot;);&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for(i=0;i&amp;lt;n;i++)&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&quot; %d&quot;,a[i]);&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&quot;\n&quot;);&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span lang=&quot;EN-US&quot;&gt;&lt;a href=&quot;http://www.programsway.com/2013/10/algorithm-of-insertion-sort.html&quot;&gt;Continued... &lt;/a&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.programsway.com/feeds/8899083320926453027/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.programsway.com/2013/10/algorithm-of-quicksort.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6893346382604416070/posts/default/8899083320926453027'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6893346382604416070/posts/default/8899083320926453027'/><link rel='alternate' type='text/html' href='http://www.programsway.com/2013/10/algorithm-of-quicksort.html' title='Algorithm of Quicksort '/><author><name>Wyes Karny</name><uri>https://plus.google.com/110965746277342011781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-b---zWeiKtw/AAAAAAAAAAI/AAAAAAAAA3Y/IEVnupjQoh8/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6893346382604416070.post-550449771982766858</id><published>2013-10-03T23:03:00.000-07:00</published><updated>2013-10-20T07:42:47.252-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Algorithm"/><category scheme="http://www.blogger.com/atom/ns#" term="Sorting"/><category scheme="http://www.blogger.com/atom/ns#" term="Time Complexity"/><title type='text'>Sorting</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div align=&quot;center&quot; class=&quot;MsoNoSpacing&quot; style=&quot;text-align: center;&quot;&gt;&lt;div style=&quot;text-align: left;&quot;&gt;Written by Kousik :&amp;nbsp;&lt;/div&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;text-align: left;&quot;&gt;“&lt;/span&gt;&lt;b style=&quot;text-align: left;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 14.0pt;&quot;&gt;Sorting&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;text-align: left;&quot;&gt;”, this word must come when you are reading C programming language as well as algorithm. This is important part of C programming and very interested problem. Many algorithms for sorting are there. In this section we discuss about several sorting algorithms and their time and space complexity.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot;&gt;Definition: &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;Input: A sequence of n numbers from linearly ordered set or totally ordered set.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;Output: A permutation of the given input sequence such that a[i] &amp;lt;=a[i+1] , where I =1,2,3…,n&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot;&gt;Sorting algorithms&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot;&gt;: &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;There are many algorithms for sorting. Every algorithm took some time for performing. Different algorithms for same problem would take different complexity. &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;MsoNoSpacing&quot; style=&quot;text-align: center;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot;&gt;Problem: Sorting&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;MsoNoSpacing&quot; style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;table border=&quot;1&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;MsoTableGrid&quot; style=&quot;border-collapse: collapse; border: none; mso-border-alt: solid black .5pt; mso-border-themecolor: text1; mso-padding-alt: 0cm 5.4pt 0cm 5.4pt; mso-yfti-tbllook: 1184;&quot;&gt; &lt;tbody&gt;&lt;tr&gt;  &lt;td style=&quot;border: solid black 1.0pt; mso-border-alt: solid black .5pt; mso-border-themecolor: text1; mso-border-themecolor: text1; padding: 0cm 5.4pt 0cm 5.4pt; width: 165.8pt;&quot; valign=&quot;top&quot; width=&quot;221&quot;&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;Name of algorithms&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;td style=&quot;border-left: none; border: solid black 1.0pt; mso-border-alt: solid black .5pt; mso-border-left-alt: solid black .5pt; mso-border-left-themecolor: text1; mso-border-themecolor: text1; mso-border-themecolor: text1; padding: 0cm 5.4pt 0cm 5.4pt; width: 166.4pt;&quot; valign=&quot;top&quot; width=&quot;222&quot;&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;   Time complexity&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;td style=&quot;border-left: none; border: solid black 1.0pt; mso-border-alt: solid black .5pt; mso-border-left-alt: solid black .5pt; mso-border-left-themecolor: text1; mso-border-themecolor: text1; mso-border-themecolor: text1; padding: 0cm 5.4pt 0cm 5.4pt; width: 146.6pt;&quot; valign=&quot;top&quot; width=&quot;195&quot;&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;Space Complexity&lt;/span&gt;&lt;/div&gt;&lt;/td&gt; &lt;/tr&gt;&lt;tr&gt;  &lt;td style=&quot;border-top: none; border: solid black 1.0pt; mso-border-alt: solid black .5pt; mso-border-themecolor: text1; mso-border-themecolor: text1; mso-border-top-alt: solid black .5pt; mso-border-top-themecolor: text1; padding: 0cm 5.4pt 0cm 5.4pt; width: 165.8pt;&quot; valign=&quot;top&quot; width=&quot;221&quot;&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;Insertion sort&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;td style=&quot;border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; mso-border-alt: solid black .5pt; mso-border-bottom-themecolor: text1; mso-border-left-alt: solid black .5pt; mso-border-left-themecolor: text1; mso-border-right-themecolor: text1; mso-border-themecolor: text1; mso-border-top-alt: solid black .5pt; mso-border-top-themecolor: text1; padding: 0cm 5.4pt 0cm 5.4pt; width: 166.4pt;&quot; valign=&quot;top&quot; width=&quot;222&quot;&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;O(&lt;/span&gt;&lt;!--[if gte msEquation 12]&gt;&lt;m:oMath&gt;&lt;m:sSup&gt;&lt;m:sSupPr&gt;&lt;span      style=&#39;font-family:&quot;Cambria Math&quot;,&quot;serif&quot;;mso-ascii-font-family:&quot;Cambria Math&quot;;      mso-hansi-font-family:&quot;Cambria Math&quot;&#39;&gt;&lt;m:ctrlPr&gt;&lt;/m:ctrlPr&gt;&lt;/span&gt;&lt;/m:sSupPr&gt;&lt;m:e&gt;&lt;i      style=&#39;mso-bidi-font-style:normal&#39;&gt;&lt;span lang=EN-US style=&#39;font-family:      &quot;Cambria Math&quot;,&quot;serif&quot;&#39;&gt;&lt;m:r&gt;n&lt;/m:r&gt;&lt;/span&gt;&lt;/i&gt;&lt;/m:e&gt;&lt;m:sup&gt;&lt;i      style=&#39;mso-bidi-font-style:normal&#39;&gt;&lt;span lang=EN-US style=&#39;font-family:      &quot;Cambria Math&quot;,&quot;serif&quot;&#39;&gt;&lt;m:r&gt;2&lt;/m:r&gt;&lt;/span&gt;&lt;/i&gt;&lt;/m:sup&gt;&lt;/m:sSup&gt;&lt;/m:oMath&gt;&lt;![endif]--&gt;&lt;!--[if !msEquation]--&gt;&lt;span style=&quot;font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 115%; mso-ansi-language: EN-IN; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-language: AR-SA; mso-bidi-theme-font: minor-bidi; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-fareast-theme-font: minor-fareast; mso-hansi-theme-font: minor-latin; mso-text-raise: -2.5pt; position: relative; top: 2.5pt;&quot;&gt;&lt;v:shapetype coordsize=&quot;21600,21600&quot; filled=&quot;f&quot; id=&quot;_x0000_t75&quot; o:preferrelative=&quot;t&quot; o:spt=&quot;75&quot; path=&quot;m@4@5l@4@11@9@11@9@5xe&quot; stroked=&quot;f&quot;&gt;   &lt;v:stroke joinstyle=&quot;miter&quot;&gt;   &lt;v:formulas&gt;    &lt;v:f eqn=&quot;if lineDrawn pixelLineWidth 0&quot;&gt;    &lt;v:f eqn=&quot;sum @0 1 0&quot;&gt;    &lt;v:f eqn=&quot;sum 0 0 @1&quot;&gt;    &lt;v:f eqn=&quot;prod @2 1 2&quot;&gt;    &lt;v:f eqn=&quot;prod @3 21600 pixelWidth&quot;&gt;    &lt;v:f eqn=&quot;prod @3 21600 pixelHeight&quot;&gt;    &lt;v:f eqn=&quot;sum @0 0 1&quot;&gt;    &lt;v:f eqn=&quot;prod @6 1 2&quot;&gt;    &lt;v:f eqn=&quot;prod @7 21600 pixelWidth&quot;&gt;    &lt;v:f eqn=&quot;sum @8 21600 0&quot;&gt;    &lt;v:f eqn=&quot;prod @7 21600 pixelHeight&quot;&gt;    &lt;v:f eqn=&quot;sum @10 21600 0&quot;&gt;   &lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:formulas&gt;   &lt;v:path gradientshapeok=&quot;t&quot; o:connecttype=&quot;rect&quot; o:extrusionok=&quot;f&quot;&gt;   &lt;o:lock aspectratio=&quot;t&quot; v:ext=&quot;edit&quot;&gt;  &lt;/o:lock&gt;&lt;/v:path&gt;&lt;/v:stroke&gt;&lt;/v:shapetype&gt;&lt;v:shape id=&quot;_x0000_i1025&quot; style=&quot;height: 13.5pt; width: 11.25pt;&quot; type=&quot;#_x0000_t75&quot;&gt;   &lt;v:imagedata chromakey=&quot;white&quot; o:title=&quot;&quot; src=&quot;file:///C:\Users\WYES\AppData\Local\Temp\msohtmlclip1\01\clip_image001.png&quot;&gt;  &lt;/v:imagedata&gt;&lt;/v:shape&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot;&gt;)&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;td style=&quot;border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; mso-border-alt: solid black .5pt; mso-border-bottom-themecolor: text1; mso-border-left-alt: solid black .5pt; mso-border-left-themecolor: text1; mso-border-right-themecolor: text1; mso-border-themecolor: text1; mso-border-top-alt: solid black .5pt; mso-border-top-themecolor: text1; padding: 0cm 5.4pt 0cm 5.4pt; width: 146.6pt;&quot; valign=&quot;top&quot; width=&quot;195&quot;&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;O(n)&lt;/span&gt;&lt;/div&gt;&lt;/td&gt; &lt;/tr&gt;&lt;tr&gt;  &lt;td style=&quot;border-top: none; border: solid black 1.0pt; mso-border-alt: solid black .5pt; mso-border-themecolor: text1; mso-border-themecolor: text1; mso-border-top-alt: solid black .5pt; mso-border-top-themecolor: text1; padding: 0cm 5.4pt 0cm 5.4pt; width: 165.8pt;&quot; valign=&quot;top&quot; width=&quot;221&quot;&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;Bubble sort&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;td style=&quot;border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; mso-border-alt: solid black .5pt; mso-border-bottom-themecolor: text1; mso-border-left-alt: solid black .5pt; mso-border-left-themecolor: text1; mso-border-right-themecolor: text1; mso-border-themecolor: text1; mso-border-top-alt: solid black .5pt; mso-border-top-themecolor: text1; padding: 0cm 5.4pt 0cm 5.4pt; width: 166.4pt;&quot; valign=&quot;top&quot; width=&quot;222&quot;&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;O(&lt;/span&gt;&lt;!--[if gte msEquation 12]&gt;&lt;m:oMath&gt;&lt;m:sSup&gt;&lt;m:sSupPr&gt;&lt;span      style=&#39;font-family:&quot;Cambria Math&quot;,&quot;serif&quot;;mso-ascii-font-family:&quot;Cambria Math&quot;;      mso-hansi-font-family:&quot;Cambria Math&quot;&#39;&gt;&lt;m:ctrlPr&gt;&lt;/m:ctrlPr&gt;&lt;/span&gt;&lt;/m:sSupPr&gt;&lt;m:e&gt;&lt;i      style=&#39;mso-bidi-font-style:normal&#39;&gt;&lt;span lang=EN-US style=&#39;font-family:      &quot;Cambria Math&quot;,&quot;serif&quot;&#39;&gt;&lt;m:r&gt;n&lt;/m:r&gt;&lt;/span&gt;&lt;/i&gt;&lt;/m:e&gt;&lt;m:sup&gt;&lt;i      style=&#39;mso-bidi-font-style:normal&#39;&gt;&lt;span lang=EN-US style=&#39;font-family:      &quot;Cambria Math&quot;,&quot;serif&quot;&#39;&gt;&lt;m:r&gt;2&lt;/m:r&gt;&lt;/span&gt;&lt;/i&gt;&lt;/m:sup&gt;&lt;/m:sSup&gt;&lt;/m:oMath&gt;&lt;![endif]--&gt;&lt;!--[if !msEquation]--&gt;&lt;span style=&quot;font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11.0pt; line-height: 115%; mso-ansi-language: EN-IN; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-language: AR-SA; mso-bidi-theme-font: minor-bidi; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-fareast-theme-font: minor-fareast; mso-hansi-theme-font: minor-latin; mso-text-raise: -2.5pt; position: relative; top: 2.5pt;&quot;&gt;&lt;v:shape id=&quot;_x0000_i1025&quot; style=&quot;height: 13.5pt; width: 11.25pt;&quot; type=&quot;#_x0000_t75&quot;&gt;   &lt;v:imagedata chromakey=&quot;white&quot; o:title=&quot;&quot; src=&quot;file:///C:\Users\WYES\AppData\Local\Temp\msohtmlclip1\01\clip_image001.png&quot;&gt;  &lt;/v:imagedata&gt;&lt;/v:shape&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot;&gt;)&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;td style=&quot;border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; mso-border-alt: solid black .5pt; mso-border-bottom-themecolor: text1; mso-border-left-alt: solid black .5pt; mso-border-left-themecolor: text1; mso-border-right-themecolor: text1; mso-border-themecolor: text1; mso-border-top-alt: solid black .5pt; mso-border-top-themecolor: text1; padding: 0cm 5.4pt 0cm 5.4pt; width: 146.6pt;&quot; valign=&quot;top&quot; width=&quot;195&quot;&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; O(n)&lt;/span&gt;&lt;/div&gt;&lt;/td&gt; &lt;/tr&gt;&lt;tr&gt;  &lt;td style=&quot;border-top: none; border: solid black 1.0pt; mso-border-alt: solid black .5pt; mso-border-themecolor: text1; mso-border-themecolor: text1; mso-border-top-alt: solid black .5pt; mso-border-top-themecolor: text1; padding: 0cm 5.4pt 0cm 5.4pt; width: 165.8pt;&quot; valign=&quot;top&quot; width=&quot;221&quot;&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;Quick sort&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;td style=&quot;border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; mso-border-alt: solid black .5pt; mso-border-bottom-themecolor: text1; mso-border-left-alt: solid black .5pt; mso-border-left-themecolor: text1; mso-border-right-themecolor: text1; mso-border-themecolor: text1; mso-border-top-alt: solid black .5pt; mso-border-top-themecolor: text1; padding: 0cm 5.4pt 0cm 5.4pt; width: 166.4pt;&quot; valign=&quot;top&quot; width=&quot;222&quot;&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; O(nlogn) (In Expected case)&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;td style=&quot;border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; mso-border-alt: solid black .5pt; mso-border-bottom-themecolor: text1; mso-border-left-alt: solid black .5pt; mso-border-left-themecolor: text1; mso-border-right-themecolor: text1; mso-border-themecolor: text1; mso-border-top-alt: solid black .5pt; mso-border-top-themecolor: text1; padding: 0cm 5.4pt 0cm 5.4pt; width: 146.6pt;&quot; valign=&quot;top&quot; width=&quot;195&quot;&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; O(n)&lt;/span&gt;&lt;/div&gt;&lt;/td&gt; &lt;/tr&gt;&lt;tr&gt;  &lt;td style=&quot;border-top: none; border: solid black 1.0pt; mso-border-alt: solid black .5pt; mso-border-themecolor: text1; mso-border-themecolor: text1; mso-border-top-alt: solid black .5pt; mso-border-top-themecolor: text1; padding: 0cm 5.4pt 0cm 5.4pt; width: 165.8pt;&quot; valign=&quot;top&quot; width=&quot;221&quot;&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;Heap sort&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;td style=&quot;border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; mso-border-alt: solid black .5pt; mso-border-bottom-themecolor: text1; mso-border-left-alt: solid black .5pt; mso-border-left-themecolor: text1; mso-border-right-themecolor: text1; mso-border-themecolor: text1; mso-border-top-alt: solid black .5pt; mso-border-top-themecolor: text1; padding: 0cm 5.4pt 0cm 5.4pt; width: 166.4pt;&quot; valign=&quot;top&quot; width=&quot;222&quot;&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; O(nlogn)&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;td style=&quot;border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; mso-border-alt: solid black .5pt; mso-border-bottom-themecolor: text1; mso-border-left-alt: solid black .5pt; mso-border-left-themecolor: text1; mso-border-right-themecolor: text1; mso-border-themecolor: text1; mso-border-top-alt: solid black .5pt; mso-border-top-themecolor: text1; padding: 0cm 5.4pt 0cm 5.4pt; width: 146.6pt;&quot; valign=&quot;top&quot; width=&quot;195&quot;&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; O(n)&lt;/span&gt;&lt;/div&gt;&lt;/td&gt; &lt;/tr&gt;&lt;tr&gt;  &lt;td style=&quot;border-top: none; border: solid black 1.0pt; mso-border-alt: solid black .5pt; mso-border-themecolor: text1; mso-border-themecolor: text1; mso-border-top-alt: solid black .5pt; mso-border-top-themecolor: text1; padding: 0cm 5.4pt 0cm 5.4pt; width: 165.8pt;&quot; valign=&quot;top&quot; width=&quot;221&quot;&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;Radix sort or bucket sort&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;td style=&quot;border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; mso-border-alt: solid black .5pt; mso-border-bottom-themecolor: text1; mso-border-left-alt: solid black .5pt; mso-border-left-themecolor: text1; mso-border-right-themecolor: text1; mso-border-themecolor: text1; mso-border-top-alt: solid black .5pt; mso-border-top-themecolor: text1; padding: 0cm 5.4pt 0cm 5.4pt; width: 166.4pt;&quot; valign=&quot;top&quot; width=&quot;222&quot;&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; O(n)&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;td style=&quot;border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; mso-border-alt: solid black .5pt; mso-border-bottom-themecolor: text1; mso-border-left-alt: solid black .5pt; mso-border-left-themecolor: text1; mso-border-right-themecolor: text1; mso-border-themecolor: text1; mso-border-top-alt: solid black .5pt; mso-border-top-themecolor: text1; padding: 0cm 5.4pt 0cm 5.4pt; width: 146.6pt;&quot; valign=&quot;top&quot; width=&quot;195&quot;&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; O(n)&lt;/span&gt;&lt;/div&gt;&lt;/td&gt; &lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;Now we will analysis about the algorithms shown in above table:&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;b&gt;&lt;u&gt;&lt;span lang=&quot;EN-US&quot;&gt;Quick Sort:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/u&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot;&gt;T&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot;&gt;his is a way of solving a problem related with sorting. This is a divide-conquer method for sorting. It works by following rule.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot; style=&quot;margin-left: 19.5pt; mso-list: l1 level1 lfo1; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot;&gt;1)&lt;span style=&quot;font-size: 7pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot;&gt;Partition the array into two parts.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot; style=&quot;margin-left: 19.5pt; mso-list: l1 level1 lfo1; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot;&gt;2)&lt;span style=&quot;font-size: 7pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot;&gt;Sort the two sub array.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot; style=&quot;margin-left: 19.5pt; mso-list: l1 level1 lfo1; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot;&gt;3)&lt;span style=&quot;font-size: 7pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot;&gt;Combine the solutions to get the solution for main problem.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;Mainly the performance of this method depends upon the position where the partition is to be done. Partition can be done by three following ways.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot; style=&quot;margin-left: 36.0pt; mso-list: l0 level1 lfo2; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot;&gt;1)&lt;span style=&quot;font-size: 7pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot;&gt;At first or last position.(Worst case)&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot; style=&quot;margin-left: 36.0pt; mso-list: l0 level1 lfo2; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot;&gt;2)&lt;span style=&quot;font-size: 7pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot;&gt;At middle position.(Best case)&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot; style=&quot;margin-left: 36.0pt; mso-list: l0 level1 lfo2; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot;&gt;3)&lt;span style=&quot;font-size: 7pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot;&gt;Randomly choose an element for partition(Randomized quick sort)&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;We will call the partitioning element by name ‘PIVOT’.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;After selecting pivot element we scan the whole array. If we find an element greater than or equal to the pivot element then we keep it at right side of pivot element and otherwise keep it in left side.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;By doing this we can claim that the pivot element gets it right position into the array. Then we recursively call the function to right and left side. So, at the end we will get the sorted array.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;First we select the middle element as pivot element.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;Now it is the time for writing the algorithm.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;Method: We use a function named QUICKSORT(S) which works recursively.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;Input: Sequence S of n elements a&lt;sub&gt;1,&lt;/sub&gt;a&lt;sub&gt;2 &lt;/sub&gt;...a&lt;sub&gt;n&lt;/sub&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;Output: The elements of S in sorted order.&lt;/span&gt;&lt;br /&gt;&lt;span lang=&quot;EN-US&quot;&gt;&lt;a href=&quot;http://www.programsway.com/2013/10/algorithm-of-quicksort.html&quot;&gt;Continued..&lt;/a&gt;. &amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.programsway.com/feeds/550449771982766858/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.programsway.com/2013/10/sorting.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6893346382604416070/posts/default/550449771982766858'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6893346382604416070/posts/default/550449771982766858'/><link rel='alternate' type='text/html' href='http://www.programsway.com/2013/10/sorting.html' title='Sorting'/><author><name>Wyes Karny</name><uri>https://plus.google.com/110965746277342011781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-b---zWeiKtw/AAAAAAAAAAI/AAAAAAAAA3Y/IEVnupjQoh8/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6893346382604416070.post-6775968480310692584</id><published>2013-09-18T08:05:00.001-07:00</published><updated>2013-09-18T08:05:20.039-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Algorithm"/><category scheme="http://www.blogger.com/atom/ns#" term="Example"/><category scheme="http://www.blogger.com/atom/ns#" term="Sorting"/><title type='text'>C Program for Merge Sort</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;#include&amp;lt;stdio.h&amp;gt;&lt;br /&gt;#include&amp;lt;stdlib.h&amp;gt;&lt;br /&gt;int *a;&lt;br /&gt;void m_sort(int,int);&lt;br /&gt;void sort(int,int,int);&lt;br /&gt;&lt;br /&gt;main()&lt;br /&gt;{&lt;br /&gt;&amp;nbsp; int n,i;&lt;br /&gt;&amp;nbsp; printf(&quot;Enter the number of elements (it should be power of 2) &quot;);&lt;br /&gt;&amp;nbsp; scanf(&quot;%d&quot;,&amp;amp;n);&lt;br /&gt;&amp;nbsp; a=(int *)calloc(n,sizeof(int));&lt;br /&gt;&amp;nbsp; printf(&quot;Enter the values &quot;);&lt;br /&gt;&amp;nbsp; for(i=0;i&amp;lt;n;i++)&lt;br /&gt;&amp;nbsp; scanf(&quot;%d&quot;,a+i);&lt;br /&gt;&amp;nbsp; m_sort(0,n-1);&lt;br /&gt;&amp;nbsp; printf(&quot;The sorted array is \n&quot;);&lt;br /&gt;&amp;nbsp; for(i=0;i&amp;lt;n;i++)&lt;br /&gt;&amp;nbsp; printf(&quot;%d &quot;,a[i]);&lt;br /&gt;&amp;nbsp; return;&lt;br /&gt;}&lt;br /&gt;void m_sort(int i,int j)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp; int mid;&lt;br /&gt;&amp;nbsp; if(j-i==0)&lt;br /&gt;&amp;nbsp; return;&lt;br /&gt;&amp;nbsp; else&lt;br /&gt;&amp;nbsp; {&lt;br /&gt;&amp;nbsp; mid=(i+j)/2;&lt;br /&gt;&amp;nbsp; m_sort(i,mid);&lt;br /&gt;&amp;nbsp; m_sort(mid+1,j);&lt;br /&gt;&amp;nbsp; sort(i,mid,j);&lt;br /&gt;&amp;nbsp; return;&lt;br /&gt;&amp;nbsp; }&lt;br /&gt;}&lt;br /&gt;void sort(int i,int mid,int j)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp; int *b,k,n,m;&lt;br /&gt;&amp;nbsp; n=i;&lt;br /&gt;&amp;nbsp; m=mid+1;&lt;br /&gt;&amp;nbsp; b=(int *)calloc((j+1),sizeof(int));&lt;br /&gt;&amp;nbsp; for(k=0;k&amp;lt;=j;k++)&lt;br /&gt;&amp;nbsp; {&lt;br /&gt;&amp;nbsp; if(n&amp;lt;=mid&amp;amp;&amp;amp;m&amp;lt;=j)&lt;br /&gt;&amp;nbsp; {&lt;br /&gt;&amp;nbsp; if(a[n]&amp;lt;a[m])&lt;br /&gt;&amp;nbsp; b[k]=a[n++];&lt;br /&gt;&amp;nbsp; else&lt;br /&gt;&amp;nbsp; b[k]=a[m++];&lt;br /&gt;&amp;nbsp; }&lt;br /&gt;&amp;nbsp; else if(n&amp;gt;mid)&lt;br /&gt;&amp;nbsp; b[k]=a[m++];&lt;br /&gt;&amp;nbsp; else&lt;br /&gt;&amp;nbsp; b[k]=a[n++];&lt;br /&gt;&amp;nbsp; }&lt;br /&gt;&amp;nbsp; for(k=0;k&amp;lt;=j;k++)&lt;br /&gt;&amp;nbsp; a[i++]=b[k];&lt;br /&gt;&amp;nbsp; return;&lt;br /&gt;}&lt;/blockquote&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.programsway.com/feeds/6775968480310692584/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.programsway.com/2013/09/c-program-for-merge-sort.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6893346382604416070/posts/default/6775968480310692584'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6893346382604416070/posts/default/6775968480310692584'/><link rel='alternate' type='text/html' href='http://www.programsway.com/2013/09/c-program-for-merge-sort.html' title='C Program for Merge Sort'/><author><name>Wyes Karny</name><uri>https://plus.google.com/110965746277342011781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-b---zWeiKtw/AAAAAAAAAAI/AAAAAAAAA3Y/IEVnupjQoh8/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6893346382604416070.post-6428908606224153447</id><published>2013-09-17T02:04:00.001-07:00</published><updated>2013-09-18T08:05:51.587-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Algorithm"/><category scheme="http://www.blogger.com/atom/ns#" term="Example"/><category scheme="http://www.blogger.com/atom/ns#" term="Sorting"/><title type='text'>Example of Quick Sort </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: #38761d;&quot;&gt;Written by Wyes&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;#include&amp;lt;stdio.h&amp;gt;&lt;br /&gt;#include&amp;lt;stdlib.h&amp;gt;&lt;br /&gt;int *a;&lt;br /&gt;void quicksort(int,int);&lt;br /&gt;int partition(int,int);&lt;br /&gt;void swap_w(int,int);&lt;br /&gt;int random_partition(int,int);&lt;br /&gt;int random_number(int,int);&lt;br /&gt;main()&lt;br /&gt;{&lt;br /&gt;&amp;nbsp; int i,j,n;&lt;br /&gt;&amp;nbsp; printf(&quot;Enter the number of elements &quot;);&lt;br /&gt;&amp;nbsp; scanf(&quot;%d&quot;,&amp;amp;n);&lt;br /&gt;&amp;nbsp; a=(int *)calloc(n,sizeof(int));&lt;br /&gt;&amp;nbsp; printf(&quot;Enter the elements\n&quot;);&lt;br /&gt;&amp;nbsp; for(i=0;i&amp;lt;n;i++)&lt;br /&gt;&amp;nbsp; scanf(&quot;%d&quot;,a+i);&lt;br /&gt;&amp;nbsp; quicksort(0,n-1);&lt;br /&gt;&amp;nbsp; printf(&quot;The sorted sequence is\n&quot;);&lt;br /&gt;&amp;nbsp; for(i=0;i&amp;lt;n;i++)&lt;br /&gt;&amp;nbsp; printf(&quot;%d &quot;,a[i]);&lt;br /&gt;&amp;nbsp; printf(&quot;\n&quot;);&lt;br /&gt;&amp;nbsp; return;&lt;br /&gt;}&lt;br /&gt;void quicksort(int i,int j)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp; int k;&lt;br /&gt;&amp;nbsp; if(j-i&amp;lt;1)&lt;br /&gt;&amp;nbsp; return;&lt;br /&gt;&amp;nbsp; else&lt;br /&gt;&amp;nbsp; {&lt;br /&gt;&amp;nbsp; k=random_partition(i,j);&lt;br /&gt;&amp;nbsp; quicksort(i,k-1);&lt;br /&gt;&amp;nbsp; quicksort(k+1,j);&lt;br /&gt;&amp;nbsp; return;&lt;br /&gt;&amp;nbsp; }&lt;br /&gt;}&lt;br /&gt;random_partition(int i,int j)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp; int k;&lt;br /&gt;&amp;nbsp; k=random_number(i,j);&lt;br /&gt;&amp;nbsp; swap_w(k,j);&lt;br /&gt;&amp;nbsp; return(partition(i,j));&lt;br /&gt;}&lt;br /&gt;int partition(i,j)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp; int m,n;&lt;br /&gt;&amp;nbsp; m=i-1;&lt;br /&gt;&amp;nbsp; for(n=i;n&amp;lt;j;n++)&lt;br /&gt;&amp;nbsp; {&lt;br /&gt;&amp;nbsp; &amp;nbsp; if(a[n]&amp;lt;=a[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;m++;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;swap_w(m,n);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;&amp;nbsp; }&lt;br /&gt;&amp;nbsp; swap_w(m+1,j);&lt;br /&gt;&amp;nbsp; return(m+1);&lt;br /&gt;}&lt;br /&gt;int random_number(int i,int j)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp; return((rand()%(j-i))+i);&lt;br /&gt;}&lt;br /&gt;void swap_w(int i,int j)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp; int temp;&lt;br /&gt;&amp;nbsp; temp=a[i];&lt;br /&gt;&amp;nbsp; a[i]=a[j];&lt;br /&gt;&amp;nbsp; a[j]=temp;&lt;br /&gt;&amp;nbsp; return;&lt;br /&gt;}&lt;/blockquote&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.programsway.com/feeds/6428908606224153447/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.programsway.com/2013/09/example-of-quick-sort.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6893346382604416070/posts/default/6428908606224153447'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6893346382604416070/posts/default/6428908606224153447'/><link rel='alternate' type='text/html' href='http://www.programsway.com/2013/09/example-of-quick-sort.html' title='Example of Quick Sort '/><author><name>Wyes Karny</name><uri>https://plus.google.com/110965746277342011781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-b---zWeiKtw/AAAAAAAAAAI/AAAAAAAAA3Y/IEVnupjQoh8/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6893346382604416070.post-7435672697026160422</id><published>2013-09-17T02:00:00.000-07:00</published><updated>2013-09-17T02:00:18.913-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Algorithm"/><category scheme="http://www.blogger.com/atom/ns#" term="Example"/><category scheme="http://www.blogger.com/atom/ns#" term="Sorting"/><title type='text'>Example of bubble sort</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: #6aa84f;&quot;&gt;Written by Kousik&lt;/span&gt;&lt;div&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;/* c program for bubble sort*/&lt;br /&gt;#include&amp;lt;stdio.h&amp;gt;&lt;br /&gt;int a[20];&lt;br /&gt;void bubble(int n)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp; &amp;nbsp;int t, i,j;&lt;br /&gt;&amp;nbsp; &amp;nbsp;for(j=n-1;j&amp;gt;0;j++)&lt;br /&gt;&amp;nbsp; &amp;nbsp;{&lt;br /&gt;&amp;nbsp; &amp;nbsp; for(i=0;i&amp;lt;j;i++)&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(a[i+1]&amp;gt;a[i])&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; &amp;nbsp;t=a[i];&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp;a[i]=a[i+1];&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp;a[i+1]=t;&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;&amp;nbsp; &amp;nbsp;}&lt;br /&gt;}&lt;br /&gt;int main()&lt;br /&gt;{&lt;br /&gt;&amp;nbsp; int n,i;&lt;br /&gt;&amp;nbsp; printf(&quot;Enter the total number of elements: &quot;);&lt;br /&gt;&amp;nbsp; scanf(&quot;%d&quot;,&amp;amp;n);&lt;br /&gt;&amp;nbsp; printf(&quot;Enter the values: &quot;);&lt;br /&gt;&amp;nbsp; for(i=0;i&amp;lt;n;i++)&lt;br /&gt;&amp;nbsp; scanf(&quot;%d&quot;,&amp;amp;a[i]);&lt;br /&gt;&amp;nbsp; bubble(n);&lt;br /&gt;&amp;nbsp; printf(&quot;The sorted sequence: &quot;);&lt;br /&gt;&amp;nbsp; for(i=0;i&amp;lt;n;i++)&lt;br /&gt;&amp;nbsp; printf(&quot; %d&quot;,a[i]);&lt;br /&gt;&amp;nbsp; return 0;&lt;br /&gt;}&amp;nbsp;&lt;/blockquote&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.programsway.com/feeds/7435672697026160422/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.programsway.com/2013/09/example-of-bubble-sort.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6893346382604416070/posts/default/7435672697026160422'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6893346382604416070/posts/default/7435672697026160422'/><link rel='alternate' type='text/html' href='http://www.programsway.com/2013/09/example-of-bubble-sort.html' title='Example of bubble sort'/><author><name>Wyes Karny</name><uri>https://plus.google.com/110965746277342011781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-b---zWeiKtw/AAAAAAAAAAI/AAAAAAAAA3Y/IEVnupjQoh8/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6893346382604416070.post-6338238589309549135</id><published>2013-08-12T22:07:00.000-07:00</published><updated>2013-08-14T22:34:12.221-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Datatypes and Variables"/><title type='text'>CONSTANTS,VARIABLES &amp; KEYWORDS IN C</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: #6aa84f;&quot;&gt;Written by Kousik :&amp;nbsp;&lt;/span&gt;&lt;br /&gt;Every programming language has a grammar. Different programming language has different grammar. So to learn C programming language we have to be familiar with that grammar which is related to C program. The grammar is nothing but CONSTANTS, VARIABLES, &amp;amp; their DATA TYPES.&lt;br /&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;b&gt;&lt;u&gt;&lt;span lang=&quot;EN-US&quot;&gt;CONSTANTS:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/u&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;There are two types of C constants. One is &lt;b&gt;PRIMARY &lt;/b&gt;and other is &lt;b&gt;SECONDARY&lt;/b&gt;.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;Primary constants are of three types.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpFirst&quot; style=&quot;mso-list: l5 level1 lfo1; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot;&gt;1)&lt;span style=&quot;font-size: 7pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot;&gt;Integer Constant&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;mso-list: l5 level1 lfo1; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot;&gt;2)&lt;span style=&quot;font-size: 7pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot;&gt;Real Constant&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpLast&quot; style=&quot;mso-list: l5 level1 lfo1; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot;&gt;3)&lt;span style=&quot;font-size: 7pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot;&gt;Character Constant&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;Secondary constants are of several types.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpFirst&quot; style=&quot;margin-left: 32.25pt; mso-add-space: auto; mso-list: l0 level1 lfo2; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot;&gt;1)&lt;span style=&quot;font-size: 7pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot;&gt;Array&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 32.25pt; mso-add-space: auto; mso-list: l0 level1 lfo2; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot;&gt;2)&lt;span style=&quot;font-size: 7pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot;&gt;Pointer&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 32.25pt; mso-add-space: auto; mso-list: l0 level1 lfo2; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot;&gt;3)&lt;span style=&quot;font-size: 7pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot;&gt;Structure&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 32.25pt; mso-add-space: auto; mso-list: l0 level1 lfo2; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot;&gt;4)&lt;span style=&quot;font-size: 7pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot;&gt;Union &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpLast&quot; style=&quot;margin-left: 32.25pt; mso-add-space: auto; mso-list: l0 level1 lfo2; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot;&gt;5)&lt;span style=&quot;font-size: 7pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot;&gt;Enum etc…&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;Now we have to primary constants first…&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 12.0pt; line-height: 115%;&quot;&gt;Integer Constants&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot;&gt;: &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;u&gt;&lt;span lang=&quot;EN-US&quot;&gt;Characteristics&lt;/span&gt;&lt;/u&gt;&lt;span lang=&quot;EN-US&quot;&gt;: a) An integer constants must have at least one digit. It must not have a decimal point.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; b) It can either positive or negative. If no sign proceeds then the integer assumed to be positive.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; c) The range for integer constants is -2147483648 to +2147483647. The range of integer constants is depend upon the compiler (visual studio, gcc &amp;nbsp;, turbo c etc).&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;u&gt;&lt;span lang=&quot;EN-US&quot;&gt;Example&lt;/span&gt;&lt;/u&gt;&lt;span lang=&quot;EN-US&quot;&gt; : 400, -421,+755 etc&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 12.0pt; line-height: 115%;&quot;&gt;Real Constants (Floating Point Constants)&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 12.0pt; line-height: 115%;&quot;&gt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;:&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;Real constants can be shown in two forms. One is fractional form and other is exponential form.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;u&gt;&lt;span lang=&quot;EN-US&quot;&gt;Characteristics&amp;nbsp;&amp;nbsp; of Fractional form&lt;/span&gt;&lt;/u&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp; :&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpFirst&quot; style=&quot;mso-list: l3 level1 lfo3; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot;&gt;a)&lt;span style=&quot;font-size: 7pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot;&gt;A real constants must have at least one digit . It must have a decimal point.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;mso-list: l3 level1 lfo3; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot;&gt;b)&lt;span style=&quot;font-size: 7pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot;&gt;It can be either positive or negative. If no sign proceeds then the integer assumed to be positive. &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpLast&quot; style=&quot;mso-list: l3 level1 lfo3; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot;&gt;c)&lt;span style=&quot;font-size: 7pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot;&gt;No blanks are allowed within a real constant.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;Example&amp;nbsp; : -69.35 , 12.00 , +39.355 etc&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;In exponential form the real is represented in two major parts&amp;nbsp; . The part coming before ‘e’ is called ‘mantissa’ and the part coming after ‘e’ called ‘exponent’ .&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;u&gt;&lt;span lang=&quot;EN-US&quot;&gt;Characteristics of exponential form&lt;/span&gt;&lt;/u&gt;&lt;span lang=&quot;EN-US&quot;&gt;: &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpFirst&quot; style=&quot;mso-list: l1 level1 lfo4; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot;&gt;a)&lt;span style=&quot;font-size: 7pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot;&gt;The word ‘e’ separate the exponential part and the mantissa part of real constants.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;mso-list: l1 level1 lfo4; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot;&gt;b)&lt;span style=&quot;font-size: 7pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot;&gt;The mantissa part may have +ve or –ve sign. . If no sign proceeds then the integer assumed to be positive.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;mso-list: l1 level1 lfo4; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot;&gt;c)&lt;span style=&quot;font-size: 7pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot;&gt;The exponent must have at least one digit.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpLast&quot; style=&quot;mso-list: l1 level1 lfo4; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot;&gt;d)&lt;span style=&quot;font-size: 7pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot;&gt;Range = -3.4e38 to +3.4e38&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 18.0pt;&quot;&gt;&lt;u&gt;&lt;span lang=&quot;EN-US&quot;&gt;Example&lt;/span&gt;&lt;/u&gt;&lt;span lang=&quot;EN-US&quot;&gt;: 3.2e-23, -0.45e+33 etc&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 18.0pt;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 12.0pt; line-height: 115%;&quot;&gt;Character Constants&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot;&gt;:&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 18.0pt;&quot;&gt;&lt;u&gt;&lt;span lang=&quot;EN-US&quot;&gt;Characteristics&lt;/span&gt;&lt;/u&gt;&lt;span lang=&quot;EN-US&quot;&gt;:&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpFirst&quot; style=&quot;mso-list: l4 level1 lfo5; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot;&gt;a)&lt;span style=&quot;font-size: 7pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot;&gt;A character constant can be a single alphabet, single digit or a single special symbol enclosed with single inverted commas.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpLast&quot; style=&quot;mso-list: l4 level1 lfo5; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot;&gt;b)&lt;span style=&quot;font-size: 7pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot;&gt;The maximum length of a character constant is 1 character.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;Example: ‘A’, ‘c’, ‘5’, ‘/’ etc&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;*Secondary constants will be discussed later.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;b&gt;&lt;u&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 14.0pt; line-height: 115%; mso-bidi-font-size: 11.0pt;&quot;&gt;VARIABLE:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/u&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;To store the data value in computer memory we have to know about VARIABLES.&amp;nbsp; Variables names are names given to location in memory. These locations can contain Integer, real, character constants .Type of variables are depending upon the type of constants. For example an integer type of variable can holds only the integer constants. The variable name is chosen by the programmer in such a way that shows its nature in the program.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;Example:&amp;nbsp; class, roll, count etc&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;Characteristics of variables:&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpFirst&quot; style=&quot;mso-list: l2 level1 lfo6; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot;&gt;a)&lt;span style=&quot;font-size: 7pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot;&gt;They must begin with a letter.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;mso-list: l2 level1 lfo6; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot;&gt;b)&lt;span style=&quot;font-size: 7pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot;&gt;A variable name is any combination of 1 to 31 alphabets, digits or underscores. The length of variables is depending upon the compiler.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;mso-list: l2 level1 lfo6; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot;&gt;c)&lt;span style=&quot;font-size: 7pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot;&gt;No special symbol other than an underscore can be used in a variable name.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpLast&quot; style=&quot;mso-list: l2 level1 lfo6; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot;&gt;d)&lt;span style=&quot;font-size: 7pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot;&gt;Uppercase and lowercase are very significant.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 18.0pt;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;b&gt;&lt;u&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 14.0pt; line-height: 115%; mso-bidi-font-size: 11.0pt;&quot;&gt;C KEYWORDS&lt;/span&gt;&lt;/u&gt;&lt;/b&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 14.0pt; line-height: 115%; mso-bidi-font-size: 11.0pt;&quot;&gt;:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-size: 14.0pt; line-height: 115%; mso-bidi-font-size: 11.0pt;&quot;&gt;C &lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot;&gt;compiler has some words whose meaning has already been explained. There are 32 keywords available in C. Different keywords have different meaning.&lt;/span&gt;&lt;/div&gt;&lt;table border=&quot;1&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;MsoTableGrid&quot; style=&quot;border-collapse: collapse; border: none; margin-left: 27.9pt; mso-border-alt: solid black .5pt; mso-border-themecolor: text1; mso-padding-alt: 0cm 5.4pt 0cm 5.4pt; mso-yfti-tbllook: 1184;&quot;&gt; &lt;tbody&gt;&lt;tr style=&quot;height: 109.3pt; mso-yfti-firstrow: yes; mso-yfti-irow: 0; mso-yfti-lastrow: yes;&quot;&gt;  &lt;td style=&quot;border: solid black 1.0pt; height: 109.3pt; mso-border-alt: solid black .5pt; mso-border-themecolor: text1; mso-border-themecolor: text1; padding: 0cm 5.4pt 0cm 5.4pt; width: 377.15pt;&quot; valign=&quot;top&quot; width=&quot;503&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;auto&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;double &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; int&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;   struct&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;Break&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;else &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;long&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; switch&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;case &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; enum &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;register&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; typedef&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;char&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;extern &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;   union&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;const&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;float &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;short &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; unsigned&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;continue &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;signed&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;   void&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;default &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;goto &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sizeof&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;volatile&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;do&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;if &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; static&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while&lt;/span&gt;&lt;/div&gt;&lt;/td&gt; &lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;To know more about c keywords you can follow LET UC C(by yashvant kanetkar) &amp;amp; ANSI C (by Balaguruswamy) .&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; `&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.programsway.com/feeds/6338238589309549135/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.programsway.com/2013/08/constantsvariables-keywords-in-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6893346382604416070/posts/default/6338238589309549135'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6893346382604416070/posts/default/6338238589309549135'/><link rel='alternate' type='text/html' href='http://www.programsway.com/2013/08/constantsvariables-keywords-in-c.html' title='CONSTANTS,VARIABLES &amp; KEYWORDS IN C'/><author><name>Wyes Karny</name><uri>https://plus.google.com/110965746277342011781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-b---zWeiKtw/AAAAAAAAAAI/AAAAAAAAA3Y/IEVnupjQoh8/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6893346382604416070.post-1668004293678410337</id><published>2013-07-28T09:14:00.000-07:00</published><updated>2013-07-28T11:59:13.644-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Algorithm"/><category scheme="http://www.blogger.com/atom/ns#" term="Divide and Conquer"/><category scheme="http://www.blogger.com/atom/ns#" term="Examples"/><title type='text'>Divide and Conquer : Explained with Example</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div class=&quot;tr_bq&quot;&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;Written by Saikat :&lt;/span&gt;&lt;/div&gt;&lt;h3&gt;&lt;span lang=&quot;EN-US&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;DIVIDE AND CONQUER ALGORITHM:&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;The most commonly used &amp;amp; convenient algorithm is the &#39;&lt;/span&gt;&lt;span class=&quot;SubtitleChar&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;line-height: 18px;&quot;&gt;Divide &amp;amp; conquer&#39;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;algorithm.&amp;nbsp;&lt;/span&gt;If a problem is tough to solve, then we can assume that this problem is made up by some small problems. Then we can break the main problem in some small sub-problems. Now we can easily solve the sub-problems. By this we can solve the whole problem very easily. This method is called Divide and Conquer method. By this method we can also develop efficient programs to solve a particular problem.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;/div&gt;&lt;h3&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;STEPS INVOLVED IN THIS ALGORITHM:&lt;/span&gt;&amp;nbsp;&lt;/span&gt;&lt;/h3&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;1) Divide the total problem into several sub problems of equal length.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;2) Obtain the solution of the individual sub problems.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;3) Combine the solutions to get the main solution.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;h3&gt;&lt;span lang=&quot;EN-US&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;ASPECT:&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;The basic aspect of this algorithm is to minimize the time complexity of a given problem as much as possible. There may be various types of algorithms to solve a particular problem. Among &amp;nbsp;&amp;nbsp;those we shall choose that one, which will take a polynomial order of time complexity, i.e. we will have to choose in such a way that it requires a least number of operations. It will be better if it takes time complexity of linear order.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: medium;&quot;&gt;&lt;span style=&quot;line-height: 20.98958396911621px;&quot;&gt;EXAMPLE:&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Take the example of the finding out the maximum and minimum from a set of integers. If we look the overall problem then we will face some challenges. So, just forget the whole problem. Now if there are two numbers then we can easily find out which is smaller and which is bigger by following algorithm.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;If(a&amp;gt;b) &amp;nbsp;then&amp;nbsp; MAX &amp;lt;- a and MIN &amp;lt;- b&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Else MAX &amp;lt;- b and MIN &amp;lt;- a&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;This is an easy problem to solve. So, we assume this problem as a unit problem and break the whole problem into sub problems.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Now look at the program and find out what we are doing in it. &lt;/span&gt;&lt;br /&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;#include&amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;#include&amp;lt;stdlib.h&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;int *a;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;typedef struct list&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp; int min,max;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;}ln;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;ln minmax(int,int);&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;int min(int,int);&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;int max(int,int);&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;main()&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp; int i,n;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp; ln ext;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp; printf(&quot;Enter the number of element &quot;);&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp; scanf(&quot;%d&quot;,&amp;amp;n);&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp; a=(int *)calloc(n,sizeof(int));&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp; printf(&quot;Enter the numbers &quot;);&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp; for(i=0;i&amp;lt;n;i++)&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp; scanf(&quot;%d&quot;,(a+i));&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp; ext=minmax(0,n-1);&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp; printf(&quot;The minmum value is %d and the maximum value is %d&quot;,ext.min,ext.max);&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp; return;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;ln minmax(int n1,int n2)&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp; ln ext,ext1,ext2;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp; if(n2-n1==1)&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp; {&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; ext.min=min(a[n1],a[n2]);&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;ext.max=max(a[n1],a[n2]);&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;return ext;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp; }&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp; else&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp; {&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp; ext1=minmax(n1,(n1+n2)/2);&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp; ext2=minmax((n1+n2)/2+1,n2);&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp; ext.min=min(ext1.min,ext2.min);&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp; ext.max=max(ext1.max,ext2.max);&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp; return ext;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp; }&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;int max(int a, int b)&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp; if(a&amp;gt;b)&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp; return a;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp; else&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp; return b;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;int min(int a, int b)&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp; if(a&amp;lt;b)&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp; return a;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp; else&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp; return b;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;/div&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.programsway.com/feeds/1668004293678410337/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.programsway.com/2013/07/divide-and-conquer-explained-with.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6893346382604416070/posts/default/1668004293678410337'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6893346382604416070/posts/default/1668004293678410337'/><link rel='alternate' type='text/html' href='http://www.programsway.com/2013/07/divide-and-conquer-explained-with.html' title='Divide and Conquer : Explained with Example'/><author><name>Wyes Karny</name><uri>https://plus.google.com/110965746277342011781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-b---zWeiKtw/AAAAAAAAAAI/AAAAAAAAA3Y/IEVnupjQoh8/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6893346382604416070.post-357673294096865419</id><published>2013-07-25T00:03:00.001-07:00</published><updated>2013-07-25T00:06:57.441-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Examples"/><category scheme="http://www.blogger.com/atom/ns#" term="Simple programs"/><title type='text'>Age Calculator Program</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;style type=&quot;text/css&quot;&gt; &lt;!--   @page { margin: 2cm }   P { margin-bottom: 0.21cm }  --&gt;&lt;/style&gt;&lt;br /&gt;&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;&lt;div style=&quot;color: #6aa84f;&quot;&gt;Posted by Kousik&lt;/div&gt;This is a program to calculate your age.&lt;/div&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;/*AGE CALCULATE*/&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;#include&amp;lt;stdio.h&amp;gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;int main()&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;{&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;int dd,dm,dy,cd,cm,cy,d,m,y;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;printf(“Enter your DATE OF BIRTH in dd mm yyyy format\n”);&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;scanf(“%d %d %d”,&amp;amp;dd,&amp;amp;dm,&amp;amp;dy);&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;printf(“Enter Current Date in dd mm yyyy format\n”);&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;scanf(“%d %d %d”,&amp;amp;cd,&amp;amp;cm,&amp;amp;cy);&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;y=cy-dy;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;if(dm&amp;gt;cm)&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;{&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;y--;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;m=12-(dm-cm);&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;if(dd&amp;gt;cd)&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;{&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;m--;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;d=30-(dd-cd);&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;}&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;else&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;{&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;d=cd-dd;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;}&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;}&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;else&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;{&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;m=cm-dm;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;if(dd&amp;gt;cd)&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;{&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;m--;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;d=30-(dd-cd);&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;}&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;else&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;{&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;d=cd-dd;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;}&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;printf(“You AGE is \n”);&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;printf(“%d days %d months %d years\n”,d,m,y);&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;}&lt;/div&gt;&lt;/blockquote&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.programsway.com/feeds/357673294096865419/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.programsway.com/2013/07/age-calculator-program.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6893346382604416070/posts/default/357673294096865419'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6893346382604416070/posts/default/357673294096865419'/><link rel='alternate' type='text/html' href='http://www.programsway.com/2013/07/age-calculator-program.html' title='Age Calculator Program'/><author><name>Wyes Karny</name><uri>https://plus.google.com/110965746277342011781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-b---zWeiKtw/AAAAAAAAAAI/AAAAAAAAA3Y/IEVnupjQoh8/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6893346382604416070.post-6354088128944184271</id><published>2013-05-17T03:55:00.000-07:00</published><updated>2013-07-11T11:55:44.621-07:00</updated><title type='text'>C program to turn binary number to decimal and decimal number to binary </title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;This is a program to convert binary to decimal&lt;br /&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;/* author- WYES KARNY */&lt;br /&gt;#include&amp;lt;stdio.h&amp;gt;&lt;br /&gt;int main()&lt;br /&gt;{&lt;br /&gt;&amp;nbsp; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;int a,rem,des=0,i=1;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;printf(&quot;Enter a binary number &quot;);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;scanf(&quot;%d&quot;,&amp;amp;a);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;while(1)&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;rem=a%10;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;a=a/10;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;des+=rem*i;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;i=i*2;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;if(a==0)&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;break;&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;printf(&quot;\nThe equevalent desimal value is %d \n&quot;,des);&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;/blockquote&gt;&lt;br /&gt;And for the Decimal to binary&lt;br /&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;#include&amp;lt;stdio.h&amp;gt;&lt;br /&gt;int main()&lt;br /&gt;{&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;int a,i,shift,bit;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;scanf(&quot;%d&quot;,&amp;amp;a);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;for(i=0;i&amp;lt;16;i++)&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;shift=a&amp;lt;&amp;lt;i;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;shift=shift&amp;gt;&amp;gt;15;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;bit=shift&amp;amp;1;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;if(bit==1)&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;printf(&quot;1&quot;);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;else&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;printf(&quot;0&quot;);&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;/blockquote&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.programsway.com/feeds/6354088128944184271/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.programsway.com/2013/05/c-program-to-turn-binary-number-to.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6893346382604416070/posts/default/6354088128944184271'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6893346382604416070/posts/default/6354088128944184271'/><link rel='alternate' type='text/html' href='http://www.programsway.com/2013/05/c-program-to-turn-binary-number-to.html' title='C program to turn binary number to decimal and decimal number to binary '/><author><name>Wyes Karny</name><uri>https://plus.google.com/110965746277342011781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-b---zWeiKtw/AAAAAAAAAAI/AAAAAAAAA3Y/IEVnupjQoh8/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6893346382604416070.post-3498150988931214570</id><published>2013-05-10T22:45:00.000-07:00</published><updated>2013-07-11T11:51:16.346-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Linked List"/><title type='text'>Implement linked list</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;Linked List is collection of data which is linked together in a&amp;nbsp;specific way.&lt;br /&gt;It is very&amp;nbsp;efficient for computer memory. It&amp;nbsp;consumes memory&amp;nbsp;usage and save memory&amp;nbsp;spaces.&lt;br /&gt;It works as Dynamic Allocation System (DMA).&lt;br /&gt;First we have to know -&lt;br /&gt;&lt;br /&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;What is Linked List?&lt;/li&gt;&lt;li&gt;Why we use Linked List?&lt;/li&gt;&lt;li&gt;How do we implement Linked list?&lt;/li&gt;&lt;/ol&gt;&lt;div&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;We will find answers for all of these questions.&lt;br /&gt;I have given some&amp;nbsp;introduction of linked list above but did not define yet.&lt;br /&gt;Linked List is a list&amp;nbsp;consisting element of structure type, which contains the data and link to the next element.&lt;br /&gt;The picture can clear your confusion.&lt;/blockquote&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://2.bp.blogspot.com/--isS6oJIxlM/UY3USaFFe4I/AAAAAAAAAhs/ZeABl12lDT0/s1600/linked_list_1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://2.bp.blogspot.com/--isS6oJIxlM/UY3USaFFe4I/AAAAAAAAAhs/ZeABl12lDT0/s1600/linked_list_1.png&quot; height=&quot;163&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;Here every block represents an element of the linked list. Every block contains two sub-blocks.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;One block is for the data, saved in the element and other for the link to the next element.&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;Next question is, why we use it. Let us consider an example, in a school, there is a class consisting 50 students. If we save their marks in an array&amp;nbsp;according to their roll numbers, then we have to&amp;nbsp;declare an array of 50 elements. If we do this then when a new student gets admission, we have no space for the new student.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;If we declare an array of 100 elements at&amp;nbsp;first&amp;nbsp;then it&amp;nbsp;would be&amp;nbsp;possible but it wastes a huge memory space.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;Therefore in this case we can use Linked List.&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;Next, implementation of linked list,&amp;nbsp;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;Here is a program to implement linked list.&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;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;#include&amp;lt;stdio.h&amp;gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;#include&amp;lt;stdlib.h&amp;gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;typedef struct link_list&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;{&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&amp;nbsp; int number;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&amp;nbsp; struct link_list *next;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;}l;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;void create(l *list);&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;void print_list(l* list);&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;main()&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;{&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&amp;nbsp; l *head;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&amp;nbsp; head=(l*)malloc(sizeof(l));&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&amp;nbsp; create(head);&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&amp;nbsp; print_list(head);&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;}&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;void create(l *list)&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;{&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&amp;nbsp; char c;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&amp;nbsp; printf(&quot;Enter the number\n&quot;);&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&amp;nbsp; scanf(&quot;%d&quot;,&amp;amp;list-&amp;gt;number);&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&amp;nbsp; printf(&quot;continue... &amp;nbsp;&quot;);&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&amp;nbsp; getchar();&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&amp;nbsp; c=getchar();&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&amp;nbsp; if(c==&#39;y&#39;)&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&amp;nbsp; {&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&amp;nbsp; list-&amp;gt;next=(l*)malloc(sizeof(l));&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&amp;nbsp; create(list-&amp;gt;next);&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&amp;nbsp; }&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&amp;nbsp; else&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&amp;nbsp; list-&amp;gt;next=NULL;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;}&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;void print_list(l* list)&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;{&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&amp;nbsp; if(list-&amp;gt;next!=NULL)&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&amp;nbsp; {&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&amp;nbsp; printf(&quot;%d &amp;nbsp;&quot;,list-&amp;gt;number);&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&amp;nbsp; print_list(list-&amp;gt;next);&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&amp;nbsp; }&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&amp;nbsp; else&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&amp;nbsp; printf(&quot;%d\n&quot;,list-&amp;gt;number);&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;}&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;(If you have any question, feel free to ask me)&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.programsway.com/feeds/3498150988931214570/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.programsway.com/2013/05/implement-linked-list.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6893346382604416070/posts/default/3498150988931214570'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6893346382604416070/posts/default/3498150988931214570'/><link rel='alternate' type='text/html' href='http://www.programsway.com/2013/05/implement-linked-list.html' title='Implement linked list'/><author><name>Wyes Karny</name><uri>https://plus.google.com/110965746277342011781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-b---zWeiKtw/AAAAAAAAAAI/AAAAAAAAA3Y/IEVnupjQoh8/s512-c/photo.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/--isS6oJIxlM/UY3USaFFe4I/AAAAAAAAAhs/ZeABl12lDT0/s72-c/linked_list_1.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6893346382604416070.post-8857432274338424597</id><published>2013-03-20T12:05:00.000-07:00</published><updated>2013-05-07T06:21:33.385-07:00</updated><title type='text'>A C Program to turn a infix expression into post-fix expression and evaluate the post-fix expression  </title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;In&amp;nbsp;Data Structures&amp;nbsp;the program infix to post fix using stack is very&amp;nbsp;important. There for here is an example for &amp;nbsp;this program. Here we use a stack named stack to store&amp;nbsp;in-stack elements.&lt;br /&gt;/* This is a program to turn a infix expression into&amp;nbsp;post-fix expression and then evaluate the expression */&lt;br /&gt;&lt;div&gt;&lt;div&gt;#include&amp;lt;stdio.h&amp;gt;&lt;/div&gt;&lt;div&gt;#include&amp;lt;stdlib.h&amp;gt;&lt;/div&gt;&lt;div&gt;#include&amp;lt;string.h&amp;gt;&lt;/div&gt;&lt;div&gt;#include&amp;lt;ctype.h&amp;gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;void push(char);&lt;/div&gt;&lt;div&gt;char pop();&lt;/div&gt;&lt;div&gt;int prt(char);&lt;/div&gt;&lt;div&gt;int eval(char *);&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;int top=-1;&lt;/div&gt;&lt;div&gt;char stack[30];&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;main()&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; int i=0,k=0;&lt;/div&gt;&lt;div&gt;&amp;nbsp; char infix[30],postfix[30];&lt;/div&gt;&lt;div&gt;&amp;nbsp; printf(&quot;Enter the expression &quot;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; scanf(&quot;%s&quot;,infix);&lt;/div&gt;&lt;div&gt;&amp;nbsp; for(i=0;i&amp;lt;strlen(infix);i++)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; if(isdigit(infix[i]))&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; postfix[k++]=infix[i];&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; else if(top==-1||prt(infix[i])&amp;gt;prt(stack[top]))&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; {&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; postfix[k++]=&#39; &#39;;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; push(infix[i]);&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; }&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;else&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;while(prt(infix[i])&amp;lt;=prt(stack[top])&amp;amp;&amp;amp;top&amp;gt;-1)&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; postfix[k++]=pop();&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;push(infix[i]);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;while(top&amp;gt;-1)&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; postfix[k++]=pop();&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;postfix[k]=&#39;\0&#39;;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; printf(&quot;The postfix expression is %s\n&quot;,postfix);&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; printf(&quot;The result is %d\n&quot;,eval(postfix));&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;void push(char a)&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;stack[++top]=a;&lt;/div&gt;&lt;div&gt;return;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;char pop()&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;return stack[top--];&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;int prt(char a)&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;if(a==&#39;+&#39;||a==&#39;-&#39;) return 1;&lt;/div&gt;&lt;div&gt;else if(a==&#39;*&#39;||a==&#39;/&#39;) return 2;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;int eval(char *str)&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; int a[30],i,n=-1,j=0;&lt;/div&gt;&lt;div&gt;&amp;nbsp; char temp[5];&lt;/div&gt;&lt;div&gt;&amp;nbsp; for(i=0;str[i]!=&#39;\0&#39;;i++)&lt;/div&gt;&lt;div&gt;&amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; if(isdigit(str[i]))&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;temp[j++]=str[i];&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; else if(str[i]==&#39; &#39;)&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;temp[j]=&#39;\0&#39;;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;a[++n]=atoi(temp);&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;j=0;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;else&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;if(j!=0)&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;temp[j]=&#39;\0&#39;;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;a[++n]=atoi(temp);&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;j=0;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;if(str[i]==&#39;+&#39;)&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;a[n-1]=a[n-1]+a[n];&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;else if(str[i]==&#39;-&#39;)&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;a[n-1]=a[n-1]-a[n];&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;else if(str[i]==&#39;*&#39;)&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;a[n-1]=a[n-1]*a[n];&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;else if(str[i]==&#39;/&#39;)&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;a[n-1]=a[n-1]/a[n];&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;n--;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; return a[0];&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The output of this program......&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://4.bp.blogspot.com/-Wma4gS2HmQM/UUoIUFLTVDI/AAAAAAAAAU0/t8BpKuYyVKU/s1600/Untitled+picture.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://4.bp.blogspot.com/-Wma4gS2HmQM/UUoIUFLTVDI/AAAAAAAAAU0/t8BpKuYyVKU/s1600/Untitled+picture.png&quot; height=&quot;78&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a href=&quot;http://adf.ly/LPeab&quot;&gt;Click here to download the program&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.programsway.com/feeds/8857432274338424597/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.programsway.com/2013/03/a-c-program-to-turn-infix-expression.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6893346382604416070/posts/default/8857432274338424597'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6893346382604416070/posts/default/8857432274338424597'/><link rel='alternate' type='text/html' href='http://www.programsway.com/2013/03/a-c-program-to-turn-infix-expression.html' title='A C Program to turn a infix expression into post-fix expression and evaluate the post-fix expression  '/><author><name>Wyes Karny</name><uri>https://plus.google.com/110965746277342011781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-b---zWeiKtw/AAAAAAAAAAI/AAAAAAAAA3Y/IEVnupjQoh8/s512-c/photo.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/-Wma4gS2HmQM/UUoIUFLTVDI/AAAAAAAAAU0/t8BpKuYyVKU/s72-c/Untitled+picture.png" height="72" width="72"/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6893346382604416070.post-416602937449537277</id><published>2013-03-10T22:11:00.002-07:00</published><updated>2013-03-12T11:18:34.668-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Simple programs"/><title type='text'>A c program to implement the mod operation </title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;This is a program show the applications the mod (%) operation.&lt;br /&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;i&gt;/&lt;/i&gt;&lt;i&gt;*This is a program to input three digit number from user and display square of first and last number */&lt;/i&gt;&lt;br /&gt;&lt;i&gt;#include&amp;lt;stdio.h&amp;gt;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;int main()&lt;/i&gt;&lt;br /&gt;&lt;i&gt;{&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;int num,rem,sqr1,sqr2;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;start:&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;printf(&quot;Enter a three digit number &amp;nbsp;&quot;);&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;scanf(&quot;%d&quot;,&amp;amp;num);&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;if(num&amp;gt;999){&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;printf(&quot;\nSorry you have Entered long number\n&quot;);&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;goto start;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;if(num&amp;lt;100){&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;printf(&quot;\nSorry you have entered short number\n&quot;);&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;goto start;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;rem=num%10;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;sqr2=rem*rem;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;num=num/10;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;num=num/10;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;sqr1=num*num;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;printf(&quot;\nThe square of the first digit is %d and the square of the last digit is %d \n&quot;,sqr1,sqr2);&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;return 0;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;}&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;The output of this program ....&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://3.bp.blogspot.com/-6hFl0muOz8g/UT1ncxGU80I/AAAAAAAAANs/TI0yYLg9CYY/s1600/Untitled+picture.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://3.bp.blogspot.com/-6hFl0muOz8g/UT1ncxGU80I/AAAAAAAAANs/TI0yYLg9CYY/s1600/Untitled+picture.png&quot; height=&quot;75&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.programsway.com/feeds/416602937449537277/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.programsway.com/2013/03/a-c-program-to-implement-mod-operation.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6893346382604416070/posts/default/416602937449537277'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6893346382604416070/posts/default/416602937449537277'/><link rel='alternate' type='text/html' href='http://www.programsway.com/2013/03/a-c-program-to-implement-mod-operation.html' title='A c program to implement the mod operation '/><author><name>Wyes Karny</name><uri>https://plus.google.com/110965746277342011781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-b---zWeiKtw/AAAAAAAAAAI/AAAAAAAAA3Y/IEVnupjQoh8/s512-c/photo.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/-6hFl0muOz8g/UT1ncxGU80I/AAAAAAAAANs/TI0yYLg9CYY/s72-c/Untitled+picture.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6893346382604416070.post-5111252593659035092</id><published>2013-03-09T05:18:00.003-08:00</published><updated>2013-03-09T05:19:26.502-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Simple programs"/><title type='text'>A C program to interchange small and capital letter alphabet</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;In C every character has a ASCII number. Here we can use this&amp;nbsp;concept for this program.&lt;br /&gt;First we take a input from user. Then we check whether it is an alphabet or not and also check whether it is &amp;nbsp;in capital or in small letter. If it is in capital then we add 32 with the character&#39;s ASCII value.&lt;br /&gt;If it is in small letter then we&amp;nbsp;subtract&amp;nbsp; 32 from the character&#39;s ASCII value.&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; For your convenience here is the ASCII chart.&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://2.bp.blogspot.com/-ub2RsfdboEw/UTszglSZqxI/AAAAAAAAANQ/AyxS1m-GpbE/s1600/Untitled+picture.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://2.bp.blogspot.com/-ub2RsfdboEw/UTszglSZqxI/AAAAAAAAANQ/AyxS1m-GpbE/s1600/Untitled+picture.png&quot; height=&quot;356&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;Now the the example ....&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;i&gt;#include&amp;lt;stdio.h&amp;gt;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;#include&amp;lt;ctype.h&amp;gt;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;int main()&lt;/i&gt;&lt;br /&gt;&lt;i&gt;{&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;char c;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;printf(&quot;Enter a &amp;nbsp;alphabet &amp;nbsp;&quot;);&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;scanf(&quot;%c&quot;,&amp;amp;c);&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(isalpha(c))&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if(c&amp;lt;&#39;a&#39;)&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;c+=32;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;\nYou have entered capital letter\nThe corresponding &amp;nbsp;small letter is &amp;nbsp;%c\n&quot;,c);&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; c-=32;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;\nYou have entered small letter\nThe corresponding &amp;nbsp;capital letter is &amp;nbsp;%c\n&quot;,c);&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;return 0;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;}&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;The output of this program will be....&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://3.bp.blogspot.com/-jEOtC4QmlBI/UTs2iRPZk0I/AAAAAAAAANY/gTAi9Dc2cIo/s1600/Untitled+picture.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://3.bp.blogspot.com/-jEOtC4QmlBI/UTs2iRPZk0I/AAAAAAAAANY/gTAi9Dc2cIo/s1600/Untitled+picture.png&quot; height=&quot;166&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.programsway.com/feeds/5111252593659035092/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.programsway.com/2013/03/a-c-program-to-interchange-small-and.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6893346382604416070/posts/default/5111252593659035092'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6893346382604416070/posts/default/5111252593659035092'/><link rel='alternate' type='text/html' href='http://www.programsway.com/2013/03/a-c-program-to-interchange-small-and.html' title='A C program to interchange small and capital letter alphabet'/><author><name>Wyes Karny</name><uri>https://plus.google.com/110965746277342011781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-b---zWeiKtw/AAAAAAAAAAI/AAAAAAAAA3Y/IEVnupjQoh8/s512-c/photo.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/-ub2RsfdboEw/UTszglSZqxI/AAAAAAAAANQ/AyxS1m-GpbE/s72-c/Untitled+picture.png" height="72" width="72"/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6893346382604416070.post-5757143508767979603</id><published>2013-03-08T19:59:00.001-08:00</published><updated>2013-03-08T19:59:18.542-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Simple programs"/><title type='text'>C Program to interchange values without using a third variable</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;We can inter change values with out using third variable.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;i&gt;//This is a program to interchange&amp;nbsp;values&amp;nbsp;of to number without using&amp;nbsp;third&amp;nbsp;variable&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;i&gt;#include&amp;lt;stdio.h&amp;gt;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;int main()&lt;/i&gt;&lt;br /&gt;&lt;i&gt;{&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;int a,b;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;printf(&quot;Enter the frist number &quot;);&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;scanf(&quot;%d&quot;,&amp;amp;a);&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;printf(&quot;\nEnter the scond number &quot;);&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;scanf(&quot;%d&quot;,&amp;amp;b);&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;a=a*b;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;b=a/b;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;a=a/b;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;printf(&quot;\nThe interchanged values are\nThe frist number is %d\nThe scond number is %d\n&quot;,a,b);&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;return 0;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;}&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;The output will be.....&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://2.bp.blogspot.com/-vlHKbUMPgSo/UTqzeTsyh7I/AAAAAAAAAM8/KJsFsKKA6Vc/s1600/Untitled+picture.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://2.bp.blogspot.com/-vlHKbUMPgSo/UTqzeTsyh7I/AAAAAAAAAM8/KJsFsKKA6Vc/s1600/Untitled+picture.png&quot; height=&quot;148&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.programsway.com/feeds/5757143508767979603/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.programsway.com/2013/03/c-program-to-interchange-values-without.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6893346382604416070/posts/default/5757143508767979603'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6893346382604416070/posts/default/5757143508767979603'/><link rel='alternate' type='text/html' href='http://www.programsway.com/2013/03/c-program-to-interchange-values-without.html' title='C Program to interchange values without using a third variable'/><author><name>Wyes Karny</name><uri>https://plus.google.com/110965746277342011781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-b---zWeiKtw/AAAAAAAAAAI/AAAAAAAAA3Y/IEVnupjQoh8/s512-c/photo.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/-vlHKbUMPgSo/UTqzeTsyh7I/AAAAAAAAAM8/KJsFsKKA6Vc/s72-c/Untitled+picture.png" height="72" width="72"/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6893346382604416070.post-9204089295656373557</id><published>2013-03-08T19:35:00.001-08:00</published><updated>2013-03-08T19:45:51.695-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Simple programs"/><title type='text'>Program to swap values using third variable</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;This is a simple program to swap the values using third variable.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: #8e7cc3;&quot;&gt;//This is a program to interchange vaules of to number using thrid variable&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #8e7cc3;&quot;&gt;#include&amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #8e7cc3;&quot;&gt;int main()&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #8e7cc3;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #8e7cc3;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;int fst_num,snd_num,trd_num;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #8e7cc3;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;printf(&quot;Enter the frist number &quot;);&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #8e7cc3;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;scanf(&quot;%d&quot;,&amp;amp;fst_num);&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #8e7cc3;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;printf(&quot;\nEnter the scond number &quot;);&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #8e7cc3;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;scanf(&quot;%d&quot;,&amp;amp;snd_num);&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #8e7cc3;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;trd_num=fst_num;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #8e7cc3;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;fst_num=snd_num;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #8e7cc3;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;snd_num=trd_num;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #8e7cc3;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;printf(&quot;\nThe interchanged values are\nThe frist number is %d\nThe scond number is %d\n&quot;,fst_num,snd_num);&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #8e7cc3;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;return 0;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #8e7cc3;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The output of this program will be.....&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://4.bp.blogspot.com/-8zPFf6PWibI/UTqwMcILYaI/AAAAAAAAAMw/PTWQ1y5Q9TA/s1600/Untitled+picture.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://4.bp.blogspot.com/-8zPFf6PWibI/UTqwMcILYaI/AAAAAAAAAMw/PTWQ1y5Q9TA/s1600/Untitled+picture.png&quot; height=&quot;136&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.programsway.com/feeds/9204089295656373557/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.programsway.com/2013/03/program-to-swap-values-using-third.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6893346382604416070/posts/default/9204089295656373557'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6893346382604416070/posts/default/9204089295656373557'/><link rel='alternate' type='text/html' href='http://www.programsway.com/2013/03/program-to-swap-values-using-third.html' title='Program to swap values using third variable'/><author><name>Wyes Karny</name><uri>https://plus.google.com/110965746277342011781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-b---zWeiKtw/AAAAAAAAAAI/AAAAAAAAA3Y/IEVnupjQoh8/s512-c/photo.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/-8zPFf6PWibI/UTqwMcILYaI/AAAAAAAAAMw/PTWQ1y5Q9TA/s72-c/Untitled+picture.png" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6893346382604416070.post-3195807614393786673</id><published>2013-03-08T19:29:00.001-08:00</published><updated>2013-03-08T19:31:01.693-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Simple programs"/><title type='text'>Program to find out area of a circle</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;This is a c program to find out the area of a circle.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;#include&amp;lt;stdio.h&amp;gt;&lt;br /&gt;#define PI 3.14&lt;br /&gt;int main()&lt;br /&gt;{&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;int redius;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;float area;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;printf(&quot;Enter the redius of the circle &quot;);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;scanf(&quot;%d&quot;,&amp;amp;redius);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;area=PI*redius*redius;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;printf(&quot;\nThe area of the circle is %5.2f\n&quot;,area);&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;&lt;br /&gt;The out put will be....&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://4.bp.blogspot.com/-UMXqjveAfw0/UTqsmn4FJeI/AAAAAAAAAMo/-aGe8U3ctCU/s1600/Untitled+picture.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://4.bp.blogspot.com/-UMXqjveAfw0/UTqsmn4FJeI/AAAAAAAAAMo/-aGe8U3ctCU/s1600/Untitled+picture.png&quot; height=&quot;97&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.programsway.com/feeds/3195807614393786673/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.programsway.com/2013/03/program-to-find-out-area-of-circle.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6893346382604416070/posts/default/3195807614393786673'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6893346382604416070/posts/default/3195807614393786673'/><link rel='alternate' type='text/html' href='http://www.programsway.com/2013/03/program-to-find-out-area-of-circle.html' title='Program to find out area of a circle'/><author><name>Wyes Karny</name><uri>https://plus.google.com/110965746277342011781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-b---zWeiKtw/AAAAAAAAAAI/AAAAAAAAA3Y/IEVnupjQoh8/s512-c/photo.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/-UMXqjveAfw0/UTqsmn4FJeI/AAAAAAAAAMo/-aGe8U3ctCU/s72-c/Untitled+picture.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6893346382604416070.post-8035356725023307055</id><published>2013-03-08T19:16:00.001-08:00</published><updated>2013-03-08T19:20:26.582-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Simple programs"/><title type='text'>Program to find out the square and cube of a number</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;This is a example of simple program to find out the square and cube of a number.&lt;br /&gt;This program can be extended to find out any power of a number using&amp;nbsp;recursion function.&lt;br /&gt;&lt;br /&gt;//This is a program to find out Square and Cube of a given number&lt;br /&gt;#include&amp;lt;stdio.h&amp;gt;&lt;br /&gt;int main()&lt;br /&gt;{&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;int num,sqrt,cube;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;printf(&quot;\nEnter a number to Square and Cube &quot;);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;scanf(&quot;%d&quot;,&amp;amp;num);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;sqrt=num*num;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;cube=num*num*num;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;printf(&quot;\nThe Square of the give number is %d\nand the cube of the give number is %d&quot;,sqrt,cube);&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;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.programsway.com/feeds/8035356725023307055/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.programsway.com/2013/03/this-is-example-of-simple-program-to.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6893346382604416070/posts/default/8035356725023307055'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6893346382604416070/posts/default/8035356725023307055'/><link rel='alternate' type='text/html' href='http://www.programsway.com/2013/03/this-is-example-of-simple-program-to.html' title='Program to find out the square and cube of a number'/><author><name>Wyes Karny</name><uri>https://plus.google.com/110965746277342011781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-b---zWeiKtw/AAAAAAAAAAI/AAAAAAAAA3Y/IEVnupjQoh8/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6893346382604416070.post-1751859245087555630</id><published>2013-02-20T23:12:00.001-08:00</published><updated>2013-03-08T04:30:32.639-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Datatypes and Variables"/><title type='text'>Datatypes &amp; Variables in C</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;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;Introduction to Data Types:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;For learning C programming we have to familiar with several types of data.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;There are five fundamental datatypes,which are all supported in any c compilers.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;They are&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;1) Integer (int)&amp;nbsp;- for integer type data.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;2) Float (float) - for floating point number.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;3) Character (char) - for a single character. (included spacial &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;character)&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;4) Double (double) - for a huge floating point number.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;5) Void (void) - for a void type variable.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;We can derive some other data type from these five fundamental datatypes.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;these derived datatypes are short integer,signed integer, &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;unsigned&lt;/span&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;white-space: pre-wrap;&quot;&gt; integer etc.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;Integer:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;        1. &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;signed&lt;/span&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;white-space: pre-wrap;&quot;&gt; int &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;    1. &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;unsigned&lt;/span&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;white-space: pre-wrap;&quot;&gt; int&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;        2. &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;signed&lt;/span&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;white-space: pre-wrap;&quot;&gt; short int &amp;nbsp; &amp;nbsp;    2. &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;unsigned&lt;/span&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;white-space: pre-wrap;&quot;&gt; short int&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;&amp;nbsp; &amp;nbsp;    &amp;nbsp;3. &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;signed&lt;/span&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;white-space: pre-wrap;&quot;&gt; long int &amp;nbsp; &amp;nbsp;    &amp;nbsp;3. &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;unsigned&lt;/span&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;white-space: pre-wrap;&quot;&gt; long int&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;Character: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;      &amp;nbsp;      &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp;Float: &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp; &amp;nbsp;  1. char &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;               1. float&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;    2. signed char &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;                  2. double&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;       3. unsigned char &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;                    3. long double&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;Now one thing is to be remembered. The &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;range of several data type depends upon compiler.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;i.e: For a 16 bit compiler the range of an integer constant &amp;nbsp; is -32768 to +32767.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;for a 32 bit compiler this range is -2147483648 to +2147483647.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;Size of data types is also depend upon compiler.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;Compiler          short&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;              &lt;/span&gt;Int           &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; long&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;16 bit&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;                  2&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;                  2&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;               4&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;32 bit&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;                  2                  &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;4&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;               4&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.programsway.com/feeds/1751859245087555630/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.programsway.com/2013/02/data-types-variable-in-c-introduction.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6893346382604416070/posts/default/1751859245087555630'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6893346382604416070/posts/default/1751859245087555630'/><link rel='alternate' type='text/html' href='http://www.programsway.com/2013/02/data-types-variable-in-c-introduction.html' title='Datatypes &amp; Variables in C'/><author><name>Wyes Karny</name><uri>https://plus.google.com/110965746277342011781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-b---zWeiKtw/AAAAAAAAAAI/AAAAAAAAA3Y/IEVnupjQoh8/s512-c/photo.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6893346382604416070.post-8638132009954565268</id><published>2013-02-16T03:28:00.001-08:00</published><updated>2013-03-03T06:40:50.607-08:00</updated><title type='text'>Introduction</title><content type='html'>The word C has spacial meaning to every programmer. C is a programming&amp;nbsp;language&amp;nbsp;developed by Dennis Ritchie at&amp;nbsp;&amp;nbsp;AT &amp;amp; T&#39;s Bell Laboratories.</content><link rel='replies' type='application/atom+xml' href='http://www.programsway.com/feeds/8638132009954565268/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.programsway.com/2013/02/introduction.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6893346382604416070/posts/default/8638132009954565268'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6893346382604416070/posts/default/8638132009954565268'/><link rel='alternate' type='text/html' href='http://www.programsway.com/2013/02/introduction.html' title='Introduction'/><author><name>Wyes Karny</name><uri>https://plus.google.com/110965746277342011781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-b---zWeiKtw/AAAAAAAAAAI/AAAAAAAAA3Y/IEVnupjQoh8/s512-c/photo.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6893346382604416070.post-3056256372694539907</id><published>2013-02-16T03:05:00.000-08:00</published><updated>2013-03-03T06:41:02.080-08:00</updated><title type='text'>Easy Ways to Learn C Programming</title><content type='html'>Here you can learn C Programming in a easy way.&lt;br /&gt;You can master C Programming within one and a half months if you learn form here.&lt;br /&gt;We&#39;ll clear your&amp;nbsp;concepts and teach you to how to think like computer&amp;nbsp;scientist.&lt;br /&gt;After every topic we will give you a assignment set to solve it yourself .&lt;br /&gt;And for solving it we will give you some&amp;nbsp;algorithms.&amp;nbsp; </content><link rel='replies' type='application/atom+xml' href='http://www.programsway.com/feeds/3056256372694539907/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.programsway.com/2013/02/easy-ways-to-learn-c-programming.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6893346382604416070/posts/default/3056256372694539907'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6893346382604416070/posts/default/3056256372694539907'/><link rel='alternate' type='text/html' href='http://www.programsway.com/2013/02/easy-ways-to-learn-c-programming.html' title='Easy Ways to Learn C Programming'/><author><name>Wyes Karny</name><uri>https://plus.google.com/110965746277342011781</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-b---zWeiKtw/AAAAAAAAAAI/AAAAAAAAA3Y/IEVnupjQoh8/s512-c/photo.jpg'/></author><thr:total>2</thr:total></entry></feed>