<?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%3Atwon069</id>
	<title>SE250:lab-1:twon069 - 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%3Atwon069"/>
	<link rel="alternate" type="text/html" href="https://wiki.kram.nz/index.php?title=SE250:lab-1:twon069&amp;action=history"/>
	<updated>2026-04-29T02:20:55Z</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:twon069&amp;diff=4579&amp;oldid=prev</id>
		<title>Mark: 5 revision(s)</title>
		<link rel="alternate" type="text/html" href="https://wiki.kram.nz/index.php?title=SE250:lab-1:twon069&amp;diff=4579&amp;oldid=prev"/>
		<updated>2008-11-03T05:18:46Z</updated>

		<summary type="html">&lt;p&gt;5 revision(s)&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Intro==&lt;br /&gt;
&lt;br /&gt;
To obtain the time required for computer to run an addition on different type of values such as short, long, double, float, integer.&lt;br /&gt;
&lt;br /&gt;
==Codes==&lt;br /&gt;
&amp;lt;pre&amp;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 main()&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
	short total = 0;&lt;br /&gt;
	long t;&lt;br /&gt;
&lt;br /&gt;
	t = clock();&lt;br /&gt;
&lt;br /&gt;
	for (long i = 0; i&amp;lt;1000000000; i++) {&lt;br /&gt;
		total++;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	t = (clock() - t);&lt;br /&gt;
	//printf(&amp;quot;%ld\n&amp;quot;, total);&lt;br /&gt;
	printf(&amp;quot;%ld /%ld\n&amp;quot;, t, CLOCKS_PER_SEC);&lt;br /&gt;
&lt;br /&gt;
	return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Result==&lt;br /&gt;
int - 2.192sec&lt;br /&gt;
&lt;br /&gt;
double - 8.262sec&lt;br /&gt;
&lt;br /&gt;
float - 8.629sec&lt;br /&gt;
&lt;br /&gt;
long - 2.404sec&lt;br /&gt;
&lt;br /&gt;
short - 2.583sec&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Summary==&lt;br /&gt;
The following problem was encountered:&lt;br /&gt;
* 1: Had no idea of how to use the function clock(), so went on google to search for appropriate use of the function. The outcome were that clock() returns a value in &amp;quot;ticks&amp;quot;, of how long the program being started for, every time it is called and assigned to a value.&lt;br /&gt;
* 2: After playing around with clock(), it always returns a value of 0, I realized the ammount of addition has to be enlarged in order to obtain more accurate and measurable value of clock(), so the loop were changed to be done 1billion times.&lt;br /&gt;
* 3: The loops and defining t as clock() took time as well within the program, so the outcome of the result cannot be accurate, as the time taken to run through the loop was counted for. However the a comparative outcome can be drawn, as double and float takes a longer time to add than int, long and short.&lt;/div&gt;</summary>
		<author><name>Mark</name></author>
	</entry>
</feed>