<?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%3Arata003</id>
	<title>SE250:lab-1:rata003 - 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%3Arata003"/>
	<link rel="alternate" type="text/html" href="https://wiki.kram.nz/index.php?title=SE250:lab-1:rata003&amp;action=history"/>
	<updated>2026-06-08T19:45:03Z</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:rata003&amp;diff=4435&amp;oldid=prev</id>
		<title>Mark: 2 revision(s)</title>
		<link rel="alternate" type="text/html" href="https://wiki.kram.nz/index.php?title=SE250:lab-1:rata003&amp;diff=4435&amp;oldid=prev"/>
		<updated>2008-11-03T05:18:43Z</updated>

		<summary type="html">&lt;p&gt;2 revision(s)&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;At first I tried assigning values to ‘a &amp;amp; b’ (variable names I initially used to address two values to be calculated) and then using another variable called ‘c’ to get the result.  At that point I didn&amp;#039;t know how to relate the clock function to this whole operation.&lt;br /&gt;
&lt;br /&gt;
Then I tried using a while loop, declaring a value for ‘a’, and incrementing the value ‘b’.  This operation was happening inside a loop, so there were countless outcomes till the condition was met.  &lt;br /&gt;
&lt;br /&gt;
I didn’t really know the purpose of using the clock function, so I asked for help and found out that I have to use the command line clock_t, and that clock() means the time at the moment.&lt;br /&gt;
&lt;br /&gt;
Then I corrected the code, so that a while loop was used to calculate the time difference, but I still didn&amp;#039;t know how the variable ‘c’ (which gave the final result of adding two no.s) relate to the whole loop.&lt;br /&gt;
&lt;br /&gt;
So after consulting the tutor it was clear that the adding operation is already happening inside the loop, so I didn&amp;#039;t have to separately do the adding operation elsewhere.&lt;br /&gt;
&lt;br /&gt;
Then I tried using only one variable, but then when I increment that variable I had trouble with the type.  As I was supposed to test it with different types, the incrementing was also changing as those types.  But the no. was always meant to increase only by 1,  because [c &amp;lt; max_num] the max_num is a int type so ‘c’ has to be of the same type for this loop to work.  To address this issue I introduce another variable, so that it didn&amp;#039;t affect by the types changing for testing.  At this point I had to change from using a ‘while’ loop to a ‘for’ loop, because of the above problem.&lt;br /&gt;
&lt;br /&gt;
After finishing the code, i had troubles debugging it.  After a while it was apparent that it was because of the max_no i used in the condition of the for loop [for (c = 0; c &amp;lt;max_num; c++)]  was too small for the final outcome to be practical.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Final code&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
#define _CRT_SECURE_NO_DEPRECATE&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 main(void)&lt;br /&gt;
{&lt;br /&gt;
	int	c;&lt;br /&gt;
	int	a = 0;&lt;br /&gt;
	clock_t t0;&lt;br /&gt;
&lt;br /&gt;
	long max_num = 10000000000;&lt;br /&gt;
&lt;br /&gt;
	t0 = clock( );&lt;br /&gt;
&lt;br /&gt;
 for (c = 0; c &amp;lt; max_num; c++){	&lt;br /&gt;
	a++;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
  printf(&amp;quot;%ld\n&amp;quot;, clock() - t0 );&lt;br /&gt;
	&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;/div&gt;</summary>
		<author><name>Mark</name></author>
	</entry>
</feed>