Lecture 7

Today was all about arrays, unfortunately we didn’t finish this lecture, but I left the last code example in there in case you are interested. Keep in mind that we have an exam next week. In the meantime here is the lecture:lecture 7

Cheers Arend

This entry was posted in Uncategorized. Bookmark the permalink.

2 Responses to Lecture 7

  1. pharaont says:

    Anyone know how to sum random numbers??

    • ahnt says:

      Hi,

      that depends if you need the numbers again or not.
      On the fly you can do:

      int i,sum=0;
      for(i=0;i<100;i++)
          sum+=rand();

      in case you need the random numbers later again, you should use an array:

      int i,sum=0;
      int N[100];
      for(i=0;i<100;i++){
          N[i]=rand();
          sum+=N[i];
      }

      Cheers Arend

Leave a Reply