<?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-5187910307609402610</id><updated>2024-08-28T18:07:48.539-07:00</updated><title type='text'>c++ Programing</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://tata317.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5187910307609402610/posts/default'/><link rel='alternate' type='text/html' href='http://tata317.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Tat</name><uri>http://www.blogger.com/profile/07950803572218813244</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>1</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5187910307609402610.post-3809280989624213234</id><published>2008-02-16T05:56:00.000-08:00</published><updated>2008-02-16T06:03:40.829-08:00</updated><title type='text'>Calculate mode and median</title><content type='html'>#include &lt;iostream&gt;&lt;br /&gt;#include &lt;conio&gt;&lt;br /&gt;#include &lt;iomanip&gt;&lt;br /&gt;&lt;br /&gt;void arrselectsort(int *[], int );&lt;br /&gt;void showarray(int *[], int );&lt;br /&gt;int CalcMode (int *[], int);&lt;br /&gt;double CalcMedian (int *[], int);&lt;br /&gt;typedef int * iptr;&lt;br /&gt;&lt;br /&gt;int main()&lt;br /&gt;{int mode;&lt;br /&gt;int val,i;&lt;br /&gt;double median;&lt;br /&gt;do{&lt;br /&gt;cout&lt;&lt;&quot;*************************************************************\n&quot;;  cout&lt;&lt;&quot;*                                                                                                                      *\n&quot;;  cout&lt;&lt;&quot;*                              Program calculate mode and median                        *\n&quot;;  cout&lt;&lt;&quot;*                                                                                                                      *\n&quot;;  cout&lt;&lt;&quot;*                                                                                                                      *\n&quot;;  cout&lt;&lt;&quot;*************************************************************\n&quot;;   cout&lt;&lt;&quot; Enter number of values :&quot;;  cin&gt;&gt;val;&lt;br /&gt;&lt;br /&gt;iptr *m= new iptr [val];&lt;br /&gt;for (i=0;i&lt;val;i++) i=&quot;new&quot; int=&quot;&quot; 1=&quot;&quot; cout=&quot;&quot;&gt;&lt;&lt;&quot; Enter &quot;&lt;&lt;val&gt;&lt;&lt;&quot; of non negatif integers each :\n&quot;;  for (int i=0;i&lt;val;i++) cin=&quot;&quot;&gt;&gt; *m[i];&lt;br /&gt;&lt;br /&gt;arrselectsort(m, val);&lt;br /&gt;&lt;br /&gt;cout&lt;&lt; &quot; The score in their ascending order are: \n:&quot;;  showarray(m, val);   cout&lt;&lt;&quot;Now program will search for mode. \n\n&quot;;  mode=CalcMode (m, val);  cout&lt;&lt;&quot;The mode is &quot;&lt;&lt;mode&gt;&lt;&lt;&quot; .&quot;&lt;&lt;endl; if=&quot;&quot; mode=&quot;=-1)&quot; cout=&quot;&quot;&gt;&lt;&lt;&quot; (mode = -1 - no mode return)\n&quot;;   median=CalcMedian (m, val);   cout&lt;&lt;setiosflags(ios::fixed||ios::left||ios showpoint=&quot;&quot; cout=&quot;&quot;&gt;&lt;&lt;setprecision 2=&quot;&quot;&gt;&lt;&lt;&quot;The median is &quot;&lt;&lt;median&gt;&lt;&lt;&quot; .&quot;&lt;&lt;endl; cout=&quot;&quot;&gt;&lt;&lt;&quot;Enter 1 to re-run program, else to quit\n&quot;;   cout&lt;&lt;&quot;Choice :&quot;;   cin&gt;&gt;i;&lt;br /&gt;}while (i==1);&lt;br /&gt;cout&lt;&lt;&quot;*************************************************************\n&quot;;  cout&lt;&lt;&quot;*                                 Thank you for using this program                          *\n&quot;;  cout&lt;&lt;&quot;*                              Program calculate mode and median                        *\n&quot;;  cout&lt;&lt;&quot;*                                                                                                                      *\n&quot;;  cout&lt;&lt;&quot;*                                                                                                                      *\n &quot;;  cout&lt;&lt;&quot;*************************************************************\n&quot;; getch (); return 0; }  void arrselectsort(int *array[], int size) {  int startscan , minindex;  int *minelem;   for ( startscan =0; startscan &lt; (size -1); startscan++)  {   minindex =startscan;   minelem = array[startscan];   for(int index =startscan +1; index&lt;size;index++) if=&quot;&quot; index=&quot;&quot;&gt;&lt;*minelem)      {         minelem =array[index];         minindex=index;      }   }    array[minindex] = array[startscan];    array[startscan] = minelem;  } }  void showarray(int *array[], int size) {  for (int i=0;i&lt;size;i++) cout=&quot;&quot;&gt;&lt;&lt;*(array[i])&lt;&lt;&quot; &quot;;   cout&lt;&lt;endl; calcmode=&quot;&quot; array=&quot;&quot; size=&quot;&quot; highest=&quot;&quot; remode=&quot;&quot; mode=&quot;new&quot; iptr=&quot;&quot; newsize=&quot;1;&quot; 2=&quot;&quot; for=&quot;&quot; int=&quot;&quot; i=&quot;new&quot; 1=&quot;1;&quot; else=&quot;&quot; 0=&quot;*array[size-1];&quot; x=&quot;0;&quot; cout=&quot;&quot;&gt;&lt;&lt;&quot;Program calculate frequnency ...3...2...1...\n\n&quot;;   cout&lt;&lt;&quot;|***********|&quot;;   for (int i=0;i&lt;(newsize);i++)   {cout&lt;&lt;setw(7)&gt;&lt;&lt;&quot;*******|&quot;;   }   cout&lt;&lt;endl; cout=&quot;&quot;&gt;&lt;&lt;&quot;|Score:     |&quot;;   for (int i=0;i&lt;newsize;i++) cout=&quot;&quot;&gt;&lt;&lt;setw(7)&gt;&lt;&lt;mode[i][0]&gt;&lt;&lt;&quot;|&quot;;   }   cout&lt;&lt;endl; cout=&quot;&quot;&gt;&lt;&lt;&quot;|Frequency: |&quot;;    for (int i=0;i&lt;newsize;i++) cout=&quot;&quot;&gt;&lt;&lt;setw(7)&gt;&lt;&lt;mode[i][1]&gt;&lt;&lt;&quot;|&quot;;   }    cout&lt;&lt;endl; cout=&quot;&quot;&gt;&lt;&lt;&quot;|***********|&quot;;   for (int i=0;i&lt;(newsize);i++)   {cout&lt;&lt;setw(7)&gt;&lt;&lt;&quot;*******|&quot;;   }   cout&lt;&lt;&quot;\n\n mode calculate...&quot;;     highest=mode[0][1];  for ( x =1; x&lt; highest =&quot; mode[x][1];&quot; remode =&quot;-1;&quot;&gt;highest)&lt;br /&gt;     {&lt;br /&gt;      highest = mode[x][1];&lt;br /&gt;      remode =mode[x][0];&lt;br /&gt;     }&lt;br /&gt;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;return remode;&lt;br /&gt;&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;double CalcMedian (int *array[], int size)&lt;br /&gt;{ double remedian;&lt;br /&gt;if( size % 2==0)&lt;br /&gt; {&lt;br /&gt;  cout&lt;&lt;&quot;Number of score is even.\n&quot;;&lt;br /&gt;&lt;br /&gt;  remedian = (*array[(size/2)]+*array[(size/2)-1]);&lt;br /&gt;  remedian=remedian/2;&lt;br /&gt;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;else&lt;br /&gt; {&lt;br /&gt;&lt;br /&gt;  cout&lt;&lt;&quot;Number of score is odd.\n&quot;;&lt;br /&gt;  remedian= *array[(size/2)];&lt;br /&gt; }&lt;br /&gt;return remedian;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/setw(7)&gt;&lt;/endl;&gt;&lt;/mode[i][1]&gt;&lt;/setw(7)&gt;&lt;/newsize;i++)&gt;&lt;/endl;&gt;&lt;/mode[i][0]&gt;&lt;/setw(7)&gt;&lt;/newsize;i++)&gt;&lt;/endl;&gt;&lt;/setw(7)&gt;&lt;/endl;&gt;&lt;/size;i++)&gt;&lt;/size;index++)&gt;&lt;/endl;&gt;&lt;/median&gt;&lt;/setprecision&gt;&lt;/setiosflags(ios::fixed||ios::left||ios&gt;&lt;/endl;&gt;&lt;/mode&gt;&lt;/val;i++)&gt;&lt;/val&gt;&lt;/val;i++)&gt;&lt;/iomanip&gt;&lt;/conio&gt;&lt;/iostream&gt;</content><link rel='replies' type='application/atom+xml' href='http://tata317.blogspot.com/feeds/3809280989624213234/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5187910307609402610/3809280989624213234' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5187910307609402610/posts/default/3809280989624213234'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5187910307609402610/posts/default/3809280989624213234'/><link rel='alternate' type='text/html' href='http://tata317.blogspot.com/2008/02/calculate-mode-and-median.html' title='Calculate mode and median'/><author><name>Tat</name><uri>http://www.blogger.com/profile/07950803572218813244</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>