<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://wiki.kram.nz/index.php?action=history&amp;feed=atom&amp;title=SE250%3Alab-1%3Ashua066</id>
	<title>SE250:lab-1:shua066 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.kram.nz/index.php?action=history&amp;feed=atom&amp;title=SE250%3Alab-1%3Ashua066"/>
	<link rel="alternate" type="text/html" href="https://wiki.kram.nz/index.php?title=SE250:lab-1:shua066&amp;action=history"/>
	<updated>2026-04-19T20:06:00Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.3</generator>
	<entry>
		<id>https://wiki.kram.nz/index.php?title=SE250:lab-1:shua066&amp;diff=4527&amp;oldid=prev</id>
		<title>Mark: 19 revision(s)</title>
		<link rel="alternate" type="text/html" href="https://wiki.kram.nz/index.php?title=SE250:lab-1:shua066&amp;diff=4527&amp;oldid=prev"/>
		<updated>2008-11-03T05:18:45Z</updated>

		<summary type="html">&lt;p&gt;19 revision(s)&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;#039;&amp;#039;&amp;#039;Lab1&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
this lab is to measure&amp;quot; how long does it take to ececute an additon (+) operation in C?&amp;quot;and use data type om C(int long short float double)&lt;br /&gt;
&lt;br /&gt;
Firstly I try to declare variables ,write a loop to do it , use int ,double , for loop&lt;br /&gt;
&lt;br /&gt;
  #include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
  #include&amp;lt;time.h&amp;gt;&lt;br /&gt;
  int main(void)&lt;br /&gt;
  {&lt;br /&gt;
     int a;&lt;br /&gt;
     int b=0;&lt;br /&gt;
     //try to make the number is big enough&lt;br /&gt;
      for (a=0;a&amp;lt;100000;a++){&lt;br /&gt;
         b=b+a;	&lt;br /&gt;
     }&lt;br /&gt;
     clock();&lt;br /&gt;
     printf(&amp;quot;%d\n&amp;quot;, b);&lt;br /&gt;
     return 0;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
But i got the wrong number , because the function clock() is in wrong way.&lt;br /&gt;
&lt;br /&gt;
  #include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
  #include&amp;lt;time.h&amp;gt;&lt;br /&gt;
  int main(void)&lt;br /&gt;
  {&lt;br /&gt;
     int a;&lt;br /&gt;
     int b=0;&lt;br /&gt;
     clock_t t0=clock();&lt;br /&gt;
     for (a=0;a&amp;lt;1000000000;a++){&lt;br /&gt;
         b=b+a;	&lt;br /&gt;
     }&lt;br /&gt;
     printf(&amp;quot;%ld\n&amp;quot;, clock()-t0);&lt;br /&gt;
     return 0;&lt;br /&gt;
  }&lt;br /&gt;
I got &lt;br /&gt;
  2422&lt;br /&gt;
&lt;br /&gt;
The answer looks OK,but the test is use other main data type ,and for &amp;quot;&amp;quot;short&amp;quot;&amp;quot;, is not bigger than 32767,so I do again,and make sure the number is big enough,so i use two for loop to do it.&lt;br /&gt;
&lt;br /&gt;
  #include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
  #include&amp;lt;time.h&amp;gt;&lt;br /&gt;
  int main(void)&lt;br /&gt;
  {&lt;br /&gt;
     int a;&lt;br /&gt;
     int b;&lt;br /&gt;
     int c=0;&lt;br /&gt;
     clock_t t0=clock();&lt;br /&gt;
     for (a=0;a&amp;lt;32767;a++){&lt;br /&gt;
         for(b=0;b&amp;lt;32767;b++){&lt;br /&gt;
             c=c+b-c;&lt;br /&gt;
         }	&lt;br /&gt;
     }&lt;br /&gt;
     printf(&amp;quot;%ld\n&amp;quot;, clock()-t0);&lt;br /&gt;
     return 0;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
and I got the answer is &lt;br /&gt;
  3406&lt;br /&gt;
&lt;br /&gt;
so later i change the data type &lt;br /&gt;
   long     3421&lt;br /&gt;
   short    3421&lt;br /&gt;
   double   27375&lt;br /&gt;
   float    7234&lt;br /&gt;
&lt;br /&gt;
All the data I collected from eng Lab (windows XP), and I did it again in GCL(windows vista) I got&lt;br /&gt;
   int      3750  &lt;br /&gt;
   long     3742 &lt;br /&gt;
   short    3774&lt;br /&gt;
   double   6155&lt;br /&gt;
   float    6146&lt;br /&gt;
&lt;br /&gt;
And I try to did it again in FCL(iMac), I got the all the data type around &lt;br /&gt;
  340&lt;/div&gt;</summary>
		<author><name>Mark</name></author>
	</entry>
</feed>