Due Wednesday, Oct. 3 at 11:59 am sharp. Late submissions will receive half marks if submitted before Dec. 3 at 11:59 AM sharp.
All work must be submitted to the Marmoset submission system. See the preamble of assignment 1 for more information.
For this assignment, you will submit C program files to Marmoset for grading. Future assignments will require that you submit C, Racket, written work, or some combination.
Your C submissions will be compiled on Ubuntu Linux using the LLVM compiler. They will be executed in the clang safe execution environment. Marmoset will award a nonzero grade when all of these conditions are met:
You should develop and test your programs prior to submission using the gedit tool on Ubuntu Linux with the CS136 RunC plugin installed. Instructors and TAs will decline to provide assistance unless the program output and clang output are both available.
Hand Marking:
When writing your C code, you should follow the guidelines and principles within the C Style and Documentation Guide found HERE.
There is no hand marking on this assignment but style and documentation in your C code will be marked in later assignments.
#include <stdio.h> int main(void){ int x; printf("The answer is %d\n",x); return 0; }Note: If you are not running VirtualBox, your program may not produce this error. In this case, create a file called "galaxy.compile.err" containing the line (without quotations): "I did not get the error!". Also, be aware that the behaviour of your setup will be different from that of marmoset and this may make errors difficult to trace in future assignments.
// gcdui.h -- Main program and user interface for GCD #include <stdio.h> #include "gcd.h" int main(void){ int x = 42; int y = 88; int gcdxy = gcd(x,y); printf("The gcd is %d\n",gcdxy); return 0; }
// Greatest Common Divisor by Euclid's Algorithm // Provides: gcd(a,b) consumes non-negative ints // a and b and produces the greatest // d such that d divides a and // d divides b int gcd(int a, int b);
// Implementation of gcd.h #include "gcd.h" int gcd(int a, int b){ if (b == 0) return a; return gcd(b, a%b); // % is remainder on division }
// file: newgame.h // Provides: startgame, guess void startgame(int n); // starts a new game in which the // game [this module] chooses a secret integer // between 1 and n, and you [the client module] // tries to guess it char guess(int x); // consumes an integer x and produces // one of 'r' or 'h' or 'l', depending on // whether x is equal to, greater than, or less than // the secret integerYour automatic player should conform to the interface defined by playnewgame.h as follows:
// Player for ordered guessing game // Provides: playgame int playgame(int n); // uses "newgame.h" to play an entire // game of size n, and produces m, // the total number of guesses actually // used by playgame to produce 'r'A sample implementation of newgame.c is provided here, but it may not be the one we use for testing. It is strongly recommended that you use this interface and the "input file" and "expected output file" features of RunC for testing. You may not use long or long long.
You may assume that n<2^31. You may not use long or long long.