Work

All assignments are to be submitted as submodules in the correct period directory for the assignment. Please see the resources page for help on linking your own repository as a submodule.

Last Class Today!

At the end of each class, 1 student will be chosen at random to 
post the day's notes online.
Notes will be posted in a document titled lct-[PERIOD].md in the dwsource 
repository on github (https://github.com/mks65/dwsource.git).
Title the note [DAY] [DATE] [TOPIC/AIM] by [AUTHOR]
For example:   Wednesday, 9/14 Variable Types by JonAlf Dyrland-Weaver
Also include at the end of the note a link to an interesting 
piece of tech/science news.
Use markdown for formatting. For markdown help go here: https://daringfireball.net/projects/markdown/basics

Work 03: Get to the point.

posted Sep 20, 2017, 10:11 AM by JonAlf Dyrland-Weaver

In order do this assignment, you need to be able to generate random numbers in c. 
  • Note: On some systems, you may be able to use other functions than the ones described below, but they are not standard for linux, so you should stay away from them for now.
  • Generating a random number in C requires 2 steps
    • Seeding the random number generator
      • srand( time(NULL) );
      • srand(<SEED>) seeds the random number generator with the provided argument.
      • If you use the same argument to srand() multiple times, you will get the exact same sequence of random numbers.
      • time(NULL) will return the current EPOCH time, it is commonly used with srand() to get new random sequences. 
    • Getting a random number
      • rand(); 
      • Returns the next random number in the sequence seeded by srand().
      • Returns an int.
    • srand() and rand() are both in <stdlib.h>
    • time() is in time.h
And now for the assignment:
  1. Create an array large enough to store 10 ints.
  2. Populate the array with random values.
  3. Set the last value in the array to 0.
  4. Print out the values in this array
  5. Create a separate array large enough to store 10 ints.
  6. USING ONLY POINTERS do the following:
    • Populate the second array with the values in the first but in reverse order
  7. Print out the values in the second array
For this assignment, do not create helper functions, put everything inside main (it won't be too long). We will talk about passing arrays and pointers are function arguments next week.

github link: https://github.com/mks65/array_swap.git

Sample output:
$ ./a.out 
The original array:
arr[0]: 1057239544
arr[1]: 1081754588
arr[2]: 180689164
arr[3]: 233522504
arr[4]: 783054129
arr[5]: 899333785
arr[6]: 704576491
arr[7]: 1549840821
arr[8]: 728322791
arr[9]: 0
The second array:
arr2[0]: 0
arr2[1]: 728322791
arr2[2]: 1549840821
arr2[3]: 704576491
arr2[4]: 899333785
arr2[5]: 783054129
arr2[6]: 233522504
arr2[7]: 180689164
arr2[8]: 1081754588
arr2[9]: 1057239544



Work 02: If you're feeling rusty, apply eul.

posted Sep 15, 2017, 7:13 AM by JonAlf Dyrland-Weaver   [ updated Sep 15, 2017, 7:53 AM ]

The time has come for you to write a c program.
  1. Look at the problems here: http://projecteuler.net/index.php?section=problems
  2. They are all math problems of some sort, pick two and write a c program to solve them.
    • Some good starters are problems 1, 5 and 6
    • Finished early? pick a third, a fourth, a fifth...
  3. Remember, c syntax is the same as java, so all your old friends (if, while, else, for...) are around.
    • You cannot declare a variable in a for loop, but you can initialize it.
    • If you want to create separate functions, do that above main() 
      • You do not need to make separate functions, but if you do, they must be declared before being used.
  4. Use scanf if you need user input (we'll talk about it Monday, but you can do man scanf to get info on it). This is not required.
Github link
https://github.com/mks65/euler.git

Work 01: 9/8

posted Sep 8, 2017, 12:49 PM by JonAlf Dyrland-Weaver

  1. Check your email for an invitation to the class forum.
  2. Accept the invite.
  3. Look at the "Welcome to the Party!" post and follow the instructions.

Work 00: 9/7

posted Sep 6, 2017, 12:26 PM by JonAlf Dyrland-Weaver

Fill out the student information form that can be found here: https://goo.gl/forms/CXaZhfCsPwc67Fg52

That's it. See, Systems is easy...

1-4 of 4