Assignments

[Note: this webpage last modified Monday, 29-Apr-2013 23:23:22 EDT]

Final exam

Some sample questions - be the computer ...

Project

Rules.

Project choices.

  1. Encryption/decryption. Possibilities: Caesar/keyword/permutation cipher, Vigenere, scytale, playfair, AES, RSA.

  2. Cryptanalysis. Breaking any of the preceding.

  3. Ncurses game. Possibilities: snake/worm/centipede, asteroids/astrosmash, maze/adventure.

  4. Equation grapher. Graph equations involving polynomials, sin, cos, tan, ...

  5. Line drawings. Save a bunch of lines as a bitmap image.

  6. Equation solver. Using Newton's method.

  7. Eliza/doctor/chat-bot.

  8. Web search/crawl.

  9. Ncurses text editor.

  10. Shell. Make your own shell, implement your own commands, login stuff, ...

  11. Text search. Search a text file for (blank), count number of times (blank), ...

  12. Ncurses planetary simulator.

  13. Scratch game/project. Possibilities: ISU adventure, ISU tour/map, typing/spelling/math tutor/game, .

  14. Computing digits of pi, e, or other numbers.

  15. Prime numbers sieve.

  16. Card games: poker, go fish, pokemon, ... .

  17. Board games: monopoly, scrabble, chess, ... .

  18. Factoring algorithms: trial division, ...

  19. Typing tutor/game.

  20. Spelling tutor/game.

  21. Math/arthmetic tutor/game.

Second exam

Topics. The exam covers everything we have done so far in terms of C programming and algorithms.

Topics that were on the first exam that are NOT on this exam include: assembly language programming, converting between binary/decimal/hexadecimal. Shell commands (cp, mv, etc.) will not be tested per se (there won't be questions where you get points just for knowing how to use the shell/terminal), but you'll need to be able to do those things to do the programming parts on the computer.

Note that the schedule has on it a few things we have not done yet (file input/output, malloc/free, time/clock, struct, enum, typedef, union). Those will not be on this test.

Okay then. The areas you should focus on for the test are...

Exam format. Same as the last time - half on paper, half on the computer.

Practice questions.

  1. On paper. What is the final value printed by the following code? Show your work for the variables and functions.
      // #includes ...
      void okay(int num, int *x, int z[]) {
        int i, total=1;
        for(i=0; i<num; i++) {
          z[i] = total * (i+1);
          total = total * (i+1);
        }
        *x = z[num-1];
      }
      int main(int argc, char *argv[]) {
        int numbers[4] = {0, 0, 0, 0};
        int howMany = 4, result = 0;
        okay(howMany, &result, numbers);
        printf("%d, %d\n", result, numbers[0]);
      }
    
  2. On paper. What is the final value printed by the following code? Show your work for the variables and functions.
      // #includes ...
      int smallestBiggerThan(int numbers[], int howMany, int what) {
        int smallSoFar = numbers[0];
        int i;
        for(i=0;i<howMany; i++) {
          if (numbers[i] < smallSoFar && numbers[i] > what)
            smallSoFar = numbers[i];
        }
        return smallSoFar;
      }
      int main(int argc, char *argv[]) {
        int nums[4] = {5, 3, 7, 2};
        int smallest = smallestBiggerThan(nums, 4, 0);
        int second = smallestBiggerThan(nums, 4, smallest);
    
        printf("%d and %d\n", smallest, second);
      }
    
  3. On paper. Explain the difference between int and float.
  4. On paper. Explain what a pointer is and what it is used for.
  5. On paper. What is a buffer overflow?
  6. On computer. Write a program that prints out the perfect cubes from 1 cubed up to 13 cubed.
  7. On computer. Make a program that draws two triangles of stars, so they together form a bigger triangle - like
    *
    **
    ***
    ****
    ***
    **
    *
    
  8. On computer. Fix the bugs in the program stored in exam2Practice1.c.
  9. On computer. Fix the bugs in the program stored in exam2Practice2.c

First exam

Topics. The exam covers everything we have done so far. In particular, focus on the following as you study.

Exam format. The exam will be in two parts - one on paper and one on the computer. Each of the practice questions is labeled as either on paper or on computer. For the on computer problems, you will have a terminal/putty, but there will be no internet access.

Practice questions.

  1. On paper. Convert between decimal, binary, and hexadecimal. Use a calculator that has these choices or Wolfram alpha to test yourself. Examples...
    Convert to binary: 99 decimal, FA hex.
    Convert to decimal: 101011 binary, 8E7 hex.
    Convert to binary: 156 decimal, 60B hex.

  2. On paper. What is the largest number that can be represented with: 2 bytes, 2 hex digits, 4 decimal digits, 7 bits?

  3. On paper. Given assembly code what does it do? Examples...

      setmem 98 5
      load 3 98
      add 3 3
      mult 3 3
      cpreg 1 3
      store 1 90
      print 90
      halt
      
      setmem 98 4
      load 1 98
      setmem 97 1
      load 2 97
      cpreg 3 1
      cpreg 4 1
      sub 4 2
      sub 4 3
      store 4 97
      print 97
      halt
      
  4. On computer. Given assembly that is partially completed, complete it so it works correctly. Examples...
      // complete so the code adds up 11+13+17+19 and prints the result.
      store 99 11
      load 1 99
      store 99 13
      load 2 99
      store 99 17
      load 3 99
      store 99 19
      load 4 99
      add 1 2
      add 1 3
      // insert instruction to finish adding values...
    
      // insert two instructions to store and print the final answer.
      
  5. On paper. Given some C code, what is the output and what happens to the variables. You would list the different values the variables had as the code ran, and would say what gets printed to the screen. Examples...

      // usual #include and int main stuff... inside of main is...
      int x = 3;
      int y = x * 5;
      int z;
      z = y + y;
      y = y - y;
      x = x / 10;
      printf("%d, %d, %d\n", z, y, x);
      
      // usual #include and int main stuff... inside of main is...
      float x, y, z;
      x = 3 / 6;
      y = x * x;
      z = x - y;
      if (z < y)
        printf("%d\n", z);
      else
        printf("%d\n", y);
      
  6. On computer. Given some C code that has a variety of syntax errors, you should be able to fix them so it works correctly. Examples...

    #include<stdio.h>
    #include<stdlib.h>
    int main(int argc, char *argv[]) {
      char choice
      printf("Even or odd?  Type E or O. ");
      scanf(%c, &choice);
      if (choice = 'E')
        printf("2 is even.\n");
      else
        printf('1 is odd.\n');
      return 0;
    }
    
    #include<stdio.h>
    #include<stdlib.h>
    float feetToMeters(float num) 
      float x;
      x = num*.914 \ 3.0;
      return x;
    
    int main(int argc, char *argv[]) {
      printf("10 feet is %d meters.\n", feetToMeters 10);
      return 0;
    }
    
  7. On computer. Be able to use the shell/putty commands to do things. Examples...
    Create a directory called examPractice in your home directory, and copy your hw5 solution there.
    Go to the directory /net/web/dept. How many .html files are in that directory?
    Copy the degrees.c file from the in class code. Put the copy in your examPractice directory, and make it named degreeCopy.c.
    Go to the / directory. What directories do you see?

  8. On paper. Questions showing basic understanding of how the computer works, what assembly language is, how programming works, etc. Examples...
    List strengths and weaknesses of hard drives versus RAM memory.
    What are the main steps in creating a program that one of your friends would be able to use?

  9. On computer. Be able to take one of our examples from class and make some basic changes to it. Examples...
    Take the degrees.c program, and make it so it prints the message "That's really cold" if the user enters a temperature less than 0 Celsius or 32 Fahrenheit.
    Take the adding.151asm program and have it add up the numbers from -100 to 200.
    Take the add.c program and make it test 30 through 39 for whether they are prime or not.

Software Environment/Installation/Login

Installing Scratch.   We will have one or two assignments using a simple programming system called Scratch. Install it by going to Scratch Download.

Installing C.   Either just use gcc by logging into the CS server using putty and your cs151xx account, or install a C compiler on your computer. If you use Linux or Mac, it is likely installed already. If you use Windows, you can install Cygwin.

It is absolutely required that you have access to a working computer with C installed (or a computer with Putty installed and an internet connection) that you have access to outside of class time. The biggest factor in your success in the course is how much time you spend programming outside of class.

Installing Putty and FileZilla.   To install the FileZilla ftp client, go to FileZilla. To work on your assignments on the CS server, you must install Putty if you are using Windows. If you are using Linux or Mac, you can just use ssh from the terminal/shell.

cs151xx login to CS server.   You will turn your assignments in by uploading your finished assignment to the Computer Science server. I have administrator access to this server and can easily grade your homeworks once they are on the server. You will receive an email giving you a username and login to the CS server. The username will be cs151xx, where xx is just a number - so the "first" student in the class will get cs15100 as their login, etc. You use either FileZilla or WinSCP with your CS login/password to upload your homework files to the CS server. This is demonstrated in the first lecture. That lecture has been recorded and is available to view in blackboard - go to blackboard for this course, and click "Tegrity Classes".

Emacs If you are programming by logging into the CS server or using Cygwin to edit your files, you have some choice about what text editor to use. Those installed on the CS server include: vi, pico, nano, emacs. If you want to use a strictly Windows text editor, you might try Notepad++. I use emacs because it does auto-indenting and other things. If you decide to use emacs, you'll need to learn the shortcuts for things. The ones I use most are the following (search online for others).

Project

Basic idea: create a "significant" program that uses most of the key programming features we have learned in class. You can choose what the program does, but your choice must be approved by Jeff.

Rules:

Homework Assignments

The homework assignments are posted in the in class code. hw1.c contains the first homework assignment, hw2.c is the second homework assignment, etc. I will announce in class and/or by email when a new assignment has been posted. Each homework assignment will list the date the assignment is due. Late assignments will not receive any credit; I will grade them just so you know how you did.

To complete a homework assignment, (1) download the assignment from the in class code, (2) make changes to the file provided to complete the assignement, (3) upload your completed assignment to the CS server before the due date. To download the file, you should browse to the in class code on the course website, right-click, and choose "Save as" or "Save target as" (depending on your browser) to save the file to your computer. For each assignment, you must download the template file to use as a starting point, make changes to this file, and then upload this file. If you do not turn in your homework in this way, I will take off points! DO NOT copy/paste into a word document, or send an email with your assignment. DO NOT change the name of the homework file - keep the name exactly the same as on the class website.

For each hw assignment, I will post a Tegrity video where I describe the hw assignment and show how my correct solution works. You will need to watch this video on your own time. The reason I do this is to FORCE you to spend some time outside of class looking at the homeworks.