SE250:lab-1:sgha014

From Marks Wiki
Revision as of 05:18, 3 November 2008 by Mark (Sọ̀rọ̀ | contribs) (1 revision(s))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

the approach i took was calling the clock function then usuing a for loop to do the addition and then calling the clock function again to work out the time elapsed to see how long it took to do the addition. In the for loop i did the addition 100000000 times.

i tried adding int and int, long and int, and double and double.... adding int and it was the fastest. double to double was the slowest.

i noticed that each time i ran it, i got a differnt time....but all were close to eachother...didnt get any weird stuff.. the tutuor suggested that we do the for loop 10 times to see what range of values we get and then we can do the average... when i did this, the values kept increasing...dont know why....maybe there was something wrong witht he loop?? coz the person next to me was getting values that wer all close to eachother....but mine kept increasing  ???

the hardest part was actually starting coz its been 4months with no C so had to remember everything again :D and i didnt really understand wat we wer supposed to do.....but after it was made clear by the tutor, it was pretty easy to complete the lab :D

oh and first in teh for loop when i was doing the addition i was doing b=a+1......but then realised that jst doing a++ for the addition is easier than introducing b as a new variable...