SE250:lab-1:mgha023

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

so i've forgotten the C++ i learnt...that made my first lab quite hard...i sat there clueless for a very long time staring at the sheet handed to me, not knowing where to begin. being an AP student has its disadvantages...coz it assumes you know 'C', but i dont! I borrowed books from the library last night in order to learn somethign for todays class, but i didnt get too far as i had a Matlab and a Java book to go through too:) so, was pretty lost this 1st class. so i opened 'the c programmign language' and tried the 'hello world programme'. btu i was not sure how to run it , let alone what compiler to use...tried using many different text editors in vain...then i asked for help, but i was still unable to figure out how to run the program...so, restarted and used the linux system...things got a little better from then on with help from my neighbour and tutors...finally executed 'hello world', then tried a program that displays the fahrenheit table...finally tried to do the worksheet.... found the clock() bit quite confusing and could do it only wiht the tutors help... i basically tried out the 'int' bit of it...making 'a' loop till it reaches 500000000, and calculate the time it took to do so...it came out to be 97000 milli seconds. i had many doubts along the way. like what 'ld' was (long decimal) and what clock_t was...gosh, left me feeling so dumb at the end of it.

 #include <time.h>
 #include <stdio.h>
 main()
 {
 int a ;
 int lower, upper, step;
 clock_t t0;

 lower=0;
 upper=500000000;
 step=1;
      
 a=lower;
   
 t0 = clock();
  
 while (a<=500000000) {
   a=a+step;
 }
 
 printf("%ld\n", clock() - t0 );
 
 return 0;
 }

my plan of action- to learn 'C' at the earliest as i have zero confidence in it ...sigh

Mgha023 11:42, 4 March 2008 (NZDT)