<?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%3Amcar147</id>
	<title>SE250:lab-1:mcar147 - 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%3Amcar147"/>
	<link rel="alternate" type="text/html" href="https://wiki.kram.nz/index.php?title=SE250:lab-1:mcar147&amp;action=history"/>
	<updated>2026-04-25T13:10:06Z</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:mcar147&amp;diff=4414&amp;oldid=prev</id>
		<title>Mark: 13 revision(s)</title>
		<link rel="alternate" type="text/html" href="https://wiki.kram.nz/index.php?title=SE250:lab-1:mcar147&amp;diff=4414&amp;oldid=prev"/>
		<updated>2008-11-03T05:18:43Z</updated>

		<summary type="html">&lt;p&gt;13 revision(s)&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{| align=&amp;quot;right&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
{| style=&amp;quot;float:right;&lt;br /&gt;
| __TOC__ &lt;br /&gt;
|}&lt;br /&gt;
|}&lt;br /&gt;
[[SE250:lab-1|Back to Lab Reports]]&lt;br /&gt;
== Lab 1 ==&lt;br /&gt;
===What I did===&lt;br /&gt;
First thing was remembering how to write C code...  With the help of a few mates working in a group we were able to recall how to write code (With the assistance of last years 131 book which Shikhar had thankfully brought)&lt;br /&gt;
Secondly, we had to figure out what the clock funtion was and how it worked.  Making use of the ever present and useful Google, a quick search brought up what the code was, the syntax for it and the way it was used.&lt;br /&gt;
===The Code===&lt;br /&gt;
 #include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
 #include &amp;lt;time.h&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 int x, z;&lt;br /&gt;
 long c;&lt;br /&gt;
 short v;&lt;br /&gt;
 float b;&lt;br /&gt;
 double n;&lt;br /&gt;
 clock_t start, end;&lt;br /&gt;
 double elapsed;&lt;br /&gt;
 &lt;br /&gt;
 int main ()&lt;br /&gt;
 {&lt;br /&gt;
 start = clock();&lt;br /&gt;
 for (z = 0; z &amp;lt; 1000000000; z++){&lt;br /&gt;
 x = x + x;&lt;br /&gt;
 }&lt;br /&gt;
 end = clock();&lt;br /&gt;
 elapsed = ((double) (end - start)) / CLOCKS_PER_SEC;&lt;br /&gt;
 printf(&amp;quot;Time taken for 1,000,000,000 int additions is %lf seconds \n \n&amp;quot;, elapsed);&lt;br /&gt;
 }&lt;br /&gt;
The rest of the program was similar to the above with the variables type being changed&lt;br /&gt;
===Results===&lt;br /&gt;
Wow computers are fast...  To do the 1 BILLION additions, it took about 4 seconds average across the board with 3.2 for ints and 4.7 for doubles and floats&lt;br /&gt;
&lt;br /&gt;
Over a period of 5 trials on this computer the average times were as follows:&lt;br /&gt;
int    =  3.2696 seconds with a range of .038 seconds&lt;br /&gt;
long   =  3.3046 seconds with a range of .005 seconds&lt;br /&gt;
short  =  3.4654 seconds with a range of .007 seconds&lt;br /&gt;
float  =  4.7582 seconds with a range of .182 seconds&lt;br /&gt;
double =  4.7746 seconds with a range of .180 seconds&lt;br /&gt;
&lt;br /&gt;
From these results it seems that long and short variables take a similar amount of time to calculate regardless of other stuff&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Afterthoughts===&lt;br /&gt;
The hardest part of this lab was recalling how to write C code, though when it started coming back most returned in a flood.  I still keep making the same stupid mistakes like forgetting the ;&amp;#039;s.&lt;/div&gt;</summary>
		<author><name>Mark</name></author>
	</entry>
</feed>