<?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%3Agfun006</id>
	<title>SE250:lab-1:gfun006 - 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%3Agfun006"/>
	<link rel="alternate" type="text/html" href="https://wiki.kram.nz/index.php?title=SE250:lab-1:gfun006&amp;action=history"/>
	<updated>2026-04-24T14:13:26Z</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:gfun006&amp;diff=4295&amp;oldid=prev</id>
		<title>Mark: 8 revision(s)</title>
		<link rel="alternate" type="text/html" href="https://wiki.kram.nz/index.php?title=SE250:lab-1:gfun006&amp;diff=4295&amp;oldid=prev"/>
		<updated>2008-11-03T05:18:41Z</updated>

		<summary type="html">&lt;p&gt;8 revision(s)&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Lab 1==&lt;br /&gt;
&lt;br /&gt;
===Problems===&lt;br /&gt;
- Tried to use the EMAC programme...but did not understand at all what was going on, so switched back to Visual Studio which I found easier to use.&lt;br /&gt;
&lt;br /&gt;
- Before I even started I was trying to remember how C worked, it took a lot of trial and error and staring at friend&amp;#039;s computers to figure that out.&lt;br /&gt;
&lt;br /&gt;
- I had NO idea how the clock() function worked until I Google&amp;#039;d it and asked some questions from friends and lecturer. &lt;br /&gt;
&lt;br /&gt;
- Trying to remember simple ENGGEN131 stuff, like proper syntax. That included { } brackets and int main(). I was horrified at my memory loss.&lt;br /&gt;
&lt;br /&gt;
- Was confused whether to use a while or a for loop, in the end settled with a for loop.&lt;br /&gt;
&lt;br /&gt;
===My code===&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;
 &lt;br /&gt;
 int x;&lt;br /&gt;
 int a;&lt;br /&gt;
 long b;&lt;br /&gt;
 short c;&lt;br /&gt;
 float d;&lt;br /&gt;
 double e;&lt;br /&gt;
 double time_elapsed; &lt;br /&gt;
 &lt;br /&gt;
 int main()&lt;br /&gt;
 {&lt;br /&gt;
 clock_t starttiming;&lt;br /&gt;
 clock_t endtiming; &lt;br /&gt;
 &lt;br /&gt;
 starttiming = clock();&lt;br /&gt;
 for (x = 0; x &amp;lt; 1000000000; x++) {&lt;br /&gt;
 &lt;br /&gt;
 a = a + a;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 endtiming = clock();&lt;br /&gt;
 time_elapsed = ((double) (endtiming - starttiming)) / CLOCKS_PER_SEC;&lt;br /&gt;
 printf(&amp;quot;Time elapsed to execute an int addition command is %lf seconds\n&amp;quot;, time_elapsed);  &lt;br /&gt;
 &lt;br /&gt;
 starttiming = clock();&lt;br /&gt;
 for (x = 0; x &amp;lt; 1000000000; x++) { &lt;br /&gt;
 &lt;br /&gt;
 b = b + b;&lt;br /&gt;
 } &lt;br /&gt;
 &lt;br /&gt;
 endtiming = clock();&lt;br /&gt;
 time_elapsed = ((double) (endtiming - starttiming)) / CLOCKS_PER_SEC;&lt;br /&gt;
 printf(&amp;quot;Time elapsed to execute an long addition command is %lf seconds\n&amp;quot;, time_elapsed); &lt;br /&gt;
 &lt;br /&gt;
*Repeat the above code from starttiming to the printf line for each main data type (i.e. just change b to c, then to d, then to e).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Explanation &amp;amp; Example===&lt;br /&gt;
What I did in the above code was for each main data type, I made it do 1 billion additions, and then print the time it took for the processor to calculate all the additions. I was going to write a code to calculate each main data type more than once, and take the average. I would of had to use another loop. But I ran out of time...so yeah :)&lt;br /&gt;
&lt;br /&gt;
An example of one of my code running are as followed:&lt;br /&gt;
&lt;br /&gt;
- Time elapsed to execute an int addition command is: 3.649000 seconds&lt;br /&gt;
&lt;br /&gt;
- Time elapsed to execute an long addition command is: 3.122000 seconds&lt;br /&gt;
&lt;br /&gt;
- Time elapsed to execute an short addition command is: 3.030900 seconds&lt;br /&gt;
&lt;br /&gt;
- Time elapsed to execute an float addition command is: 4.826000 seconds&lt;br /&gt;
&lt;br /&gt;
- Time elapsed to execute an double addition command is: 4.746000 seconds&lt;/div&gt;</summary>
		<author><name>Mark</name></author>
	</entry>
</feed>